Registry / database / pg-range-parser

pg-range-parser

JSON →
library1.0.0jsnpmunverified

Minimum viable parser and serializer for PostgreSQL range types (e.g., int4range, tsrange, daterange). Version 1.0.0 is stable but unmaintained since 2015. Converts between Postgres string representation like '[2015-01-01,2015-02-01)' and structured objects {start:{value,inclusive}, end:{value,inclusive}}. No dependencies, works in Node.js only. Not actively developed; alternative is node-pg's built-in range type support or pg-range.

npm install pg-range-parser
INSTALL
IMPORT
SIG · PG-RANGE-PARSER
P
pg-range-parser
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const pgRangeType = require('pg-range-parser');
import pgRangeType from 'pg-range-parser';
CJS-only; no ESM or named export.
parse
const { parse } = require('pg-range-parser');
Destructure the returned object for direct access.
serialize
const { serialize } = require('pg-range-parser');
Destructure for direct access.

Parse a Postgres range string into an object, then serialize it back.

const pgRangeType = require('pg-range-parser'); const rangeStr = '[2015-01-01,2015-02-01)'; const parsed = pgRangeType.parse(rangeStr); console.log(parsed); // { start: { value: '2015-01-01', inclusive: true }, // end: { value: '2015-02-01', inclusive: false } } const serialized = pgRangeType.serialize({ start: { value: '2015-01-01', inclusive: true }, end: { value: '2015-02-01', inclusive: false } }); console.log(serialized); // '[2015-01-01,2015-02-01)'
Debug
Known issues
deprecatedLibrary is unmaintained since 2015; use pg-range or node-pg's built-in range parser instead.
fix
Migrate to pg-range or upgrade to node-pg v8+ which includes built-in range parsing.
affects: >=1.0.0
gotchaDoes not validate input; malformed range strings may throw or return undefined.
fix
Always validate input before calling parse().
affects: >=1.0.0
gotchaInfinite bounds (e.g., '(,)') are not supported; will throw.
fix
Handle infinite bounds manually or use a library that supports them.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'pg-range-parser'
Package not installed; typo in package name.
fix
Run 'npm install pg-range-parser' and double-check the spelling.
pgRangeType.parse is not a function
Import method mismatch; using ES import on CJS module without default interop.
fix
Use require('pg-range-parser') instead of import.
TypeError: Invalid range string
Input string does not match Postgres range format.
fix
Ensure the string follows pattern like '[start,end)', with parentheses/brackets and comma.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
pg-range-parser — npm install pg-range-parser · libregistry