A lightweight zero-dependency library for parsing and serializing PostgreSQL composite type values as strings. Version 0.3.0 is the current stable release. It provides two functions: parse, which returns an iterable of string or null values from a formatted composite string, and serialize, which produces a composite string from an iterable. The library is ESM- and CJS-compatible, ships TypeScript definitions, and has no runtime dependencies. It is intended for use with the pg client or raw PostgreSQL connections. Minimal API surface with no additional configuration needed.
npm install postgres-compositeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Parses a PostgreSQL composite string into an array of strings/null and serializes an array back to a composite string.
Use [...parse(value)] or Array.from(parse(value)) to get an array.
Ensure the input iterable has at least one element before calling serialize.
Only use parse with strings produced by PostgreSQL's composite output routine (e.g., from pg query results).
Handle null explicitly; they are distinct from empty strings.
Use named imports: import { parse, serialize } from 'postgres-composite'Ensure at least one element: serialize(['']) or serialize([null]) if you need one value.
Use [...parse(value)] or Array.from(parse(value)) to iterate.
No dependency data recorded yet.