Registry / database / postgres-array

postgres-array

JSON →
library3.0.4jsnpmunverified

Parse PostgreSQL array column strings into JavaScript arrays. Current stable version is 3.0.4 (Node >=12). Released infrequently; latest version focused on ESM modernization. Key differentiator: minimal dependency, lightweight parser with optional transform function for type coercion. Alternative to manual parsing or using full pg driver within specific contexts.

database
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.

ESM-only since v3; named export. The default export was removed.

import { parse } from 'postgres-array'

CommonJS require is available for Node <12 or legacy projects, but v3 encourages ESM.

const { parse } = require('postgres-array')

TypeScript types are included; use type-only import for types.

import type { ParseFunction } from 'postgres-array'

No default export in v3.

import { parse } from 'postgres-array'

Parse a PostgreSQL array string with a transform function to convert string values to numbers.

import { parse } from 'postgres-array'; const result = parse('{1,2,3}', (value) => parseInt(value, 10)); console.log(result); // [1, 2, 3]
Debug
Known footguns
breakingv3 removed CommonJS default export; CJS users must switch to named destructuring.
gotchaTransform function is called for every non-null element; nulls are preserved as `null`.
gotchaInput must be a properly formatted PostgreSQL array string; invalid input may cause unexpected behavior.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
mj12bot
1
ahrefsbot
1
Resources