{"library":"postgres-range","title":"PostgreSQL Range Type Parser","description":"This library provides parsing and serialization capabilities for PostgreSQL's native range data types. It allows developers to convert PostgreSQL range strings (e.g., `[0,5)`) into a rich `Range` object with methods for querying properties like boundedness and inclusivity, and for performing operations such as point and range containment checks. The current stable version is 1.1.4. Releases appear to be driven by feature additions and bug fixes rather than a strict time-based cadence, as indicated by the recent v1.1.4 update addressing type definitions and adding a `toPostgres` method. Its key differentiator is its focused utility on PostgreSQL's specific range string format, providing a dedicated `Range` object API rather than a general-purpose interval library.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install postgres-range"],"cli":null},"imports":["import { parse, serialize, Range, RANGE_LB_INC, RANGE_UB_INC } from 'postgres-range';","const postgresRange = require('postgres-range');","import type { Range } from 'postgres-range';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parse, serialize, Range, RANGE_LB_INC, RANGE_UB_INC } from 'postgres-range';\n\n// Parse a half-open integer range from a string\nconst intRange = parse('[0,5)', (value) => parseInt(value, 10));\nconsole.log(`Range: [${intRange.lower}, ${intRange.upper})`);\nconsole.log(`Is bounded: ${intRange.isBounded()}`);\nconsole.log(`Lower bound closed: ${intRange.isLowerBoundClosed()}`);\nconsole.log(`Upper bound closed: ${intRange.isUpperBoundClosed()}`);\nconsole.log(`Contains point 4: ${intRange.containsPoint(4)}`);\n\n// Parse a nested range for containment check\nconst subRange = parse('[1,2]', (value) => parseInt(value, 10));\nconsole.log(`Contains sub-range [1,2]: ${intRange.containsRange(subRange)}`);\n\n// Parse an empty range\nconst emptyRange = parse('empty');\nconsole.log(`Is empty range: ${emptyRange.isEmpty()}`);\n\n// Serialize a custom range with both bounds inclusive\nconst customRange = new Range(10, 20, RANGE_LB_INC | RANGE_UB_INC); // Represents [10,20]\nconsole.log(`Serialized custom range [10,20]: ${serialize(customRange)}`);\n\n// Example with floating point numbers\nconst floatRange = parse('(0.5, 9.9]', parseFloat);\nconsole.log(`Float range: (${floatRange.lower}, ${floatRange.upper}]`);\nconsole.log(`Contains point 7.2: ${floatRange.containsPoint(7.2)}`);","lang":"typescript","description":"This quickstart demonstrates parsing various PostgreSQL range strings, checking their properties and contents, and serializing a `Range` object back into a string, including custom boundary types.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}