Parse and serialize PostgreSQL range types.
pg-nano
.
import { Range, RangeFlag, RangeParserError } from 'pg-nano'
An enumeration of flags used to describe range properties.
Empty
: Indicates an empty rangeLowerBoundClosed
: Indicates a closed lower boundUpperBoundClosed
: Indicates a closed upper bound
A custom error class for range parsing errors.
A class representing a range of values of type T
.
constructor(lower: T | null, upper: T | null, flags: RangeFlag[] = [])
hasFlag(flag: RangeFlag): boolean
: Checks if the range has a specific flaghasFlags(flags: RangeFlag[]): boolean
: Checks if the range has all the specified flagsisEmpty(): boolean
: Checks if the range is emptyisLowerBoundClosed(): boolean
: Checks if the lower bound is closedisUpperBoundClosed(): boolean
: Checks if the upper bound is closedcontainsPoint(point: T): boolean
: Checks if the range contains a specific pointcontainsRange(range: Range<T>): boolean
: Checks if the range contains another range
Parses a string representation of a range into a Range<T>
object.
Serializes a Range<T>
object into its string representation.