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 [email protected] 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 [email protected] 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 |
|---|---|---|---|
[email protected] | ISC | 64-bit integer parsing | 0 |
[email protected] | MIT | Array parsing | 0 |
[email protected] | MIT | Bytea decoding | 0 |
[email protected] | MIT | Date and timestamp parsing | 0 |
[email protected] | MIT | Interval parsing | 1 — archived xtend |
Immutable release
Version 1.0.0 was built from commit 14f3e2103f190259a1ca515493034d159c08707a. Verdaccio, official npm, and the GitHub release serve the same 16,581-byte tarball.
Artifact SHA-256
e627fe7a74bb5c83e1b4bbdccd06eef27cb216c1ac25ab38c9c50caf3fd4a488
The package contains 29 files, unpacks to 54,718 bytes, carries an npm registry signature, and declares no production dependencies. See the immutable GitHub release evidence.
Reference