Lookup
getTypeParser(oid, format?)
Returns the registered text or binary parser. Unknown OIDs retain the baseline identity-parser behavior.
PostgreSQL parsers · maintained compatibility
The public pg-types@2.2.0 parser contract, rebuilt as a dependency-free package with current ESM and TypeScript entry points.
The former five-package parser chain is maintained in-tree with exact provenance and license notices. Archived xtend@4.0.2 is removed from the production graph.
Public surface
The root preserves the historical callable methods, parser factory, built-in OIDs, and lib/* entry points.
Lookup
getTypeParser(oid, format?)Returns the registered text or binary parser. Unknown OIDs retain the baseline identity-parser behavior.
Registration
setTypeParser(oid, parser)Registers a text parser while isolating dangerous property names from shared object prototypes.
Registration
setTypeParser(oid, format, parser)Registers a parser for the explicit text or binary format.
Array parsing
arrayParser.create(source, transform?)Creates the historical incremental PostgreSQL array parser with an optional value transform.
OID constants
builtins and TypeIdExports the complete 2.2.0 built-in OID map. TypeId is a non-enumerable runtime alias.
Module formats
CommonJS and ESM exports share function identities; TypeScript 3.9 and current compilers receive matching declarations.
Scoped import
var types = require('@stackline/pg-types')
var parse = types.getTypeParser(types.builtins.TIMESTAMPTZ)
parse('2026-08-30 12:00:00+00')
Custom parser
var types = require('pg-types')
types.setTypeParser(types.builtins.INT8, function (value) {
return parseInt(value, 10)
})
Compatibility boundary
Scalar, array, date, interval, bytea, JSON, and binary fixtures preserve the baseline output. Hardening is deliberately limited to unsafe registry keys and malformed timestamp prefixes.
Preserved
Text and binary registration, root enumerability, built-in OIDs, deep files, and parser output remain compatible.
Hardened
__proto__, prototype, and constructor cannot mutate shared prototypes.
Bounded
Timestamp text must begin with a year, matching PostgreSQL output and avoiding the baseline's repeated regex scan.
Additive
New entry points and the declaration-promised alias are additive without changing the enumerable CommonJS root.
Production closure
The package vendors exact compatible source instead of installing the former transitive graph. Each component keeps its original notice.
| Baseline | License | Role | Installed children removed |
|---|---|---|---|
pg-int8@1.0.1 | ISC | 64-bit integer parsing | 0 |
postgres-array@2.0.0 | MIT | Array parsing | 0 |
postgres-bytea@1.0.1 | MIT | Bytea decoding | 0 |
postgres-date@1.0.7 | MIT | Date and timestamp parsing | 0 |
postgres-interval@1.2.0 | MIT | Interval parsing | 1 — archived xtend |
Verified npm publication
Version 1.0.1 was published from commit 4786606e1d55b9d3a158bbe86819f6db1653b68e. The official npm tarball is 17,393 bytes and matches the reviewed release artifact byte for byte.
Artifact SHA-256
14c023ee505bc9de5ffef67255fce657b82b09ad77dbf4320dcbfb1d543aab72
The package declares no production dependencies. Its signed npm provenance identifies the exact source commit and successful GitHub Actions publication. Install the verified npm release.
Reference