PostgreSQL parsers · maintained compatibility

@stackline/pg-types

The public [email protected] parser contract, rebuilt as a dependency-free package with current ESM and TypeScript entry points.

  • v1.0.0
  • Node.js ≥4
  • CommonJS + ESM
  • TypeScript 3.9+
  • Zero runtime dependencies
  • MIT

No installed parser dependencies

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

Register and resolve PostgreSQL parsers

The root preserves the historical callable methods, parser factory, built-in OIDs, and lib/* entry points.

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 TypeId

Exports the complete 2.2.0 built-in OID map. TypeId is a non-enumerable runtime alias.

Module formats

CommonJS, ESM, and declarations

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

Valid PostgreSQL values keep 2.2.0 behavior

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

Parser results and overloads

Text and binary registration, root enumerability, built-in OIDs, deep files, and parser output remain compatible.

Hardened

Prototype-safe registries

__proto__, prototype, and constructor cannot mutate shared prototypes.

Bounded

Malformed timestamps

Timestamp text must begin with a year, matching PostgreSQL output and avoiding the baseline's repeated regex scan.

Additive

Explicit ESM and runtime TypeId

New entry points and the declaration-promised alias are additive without changing the enumerable CommonJS root.

Production closure

Five parser sources, one reviewed artifact

The package vendors exact compatible source instead of installing the former transitive graph. Each component keeps its original notice.

In-tree compatibility components and dependency decisions
Baseline License Role Installed children removed
[email protected]ISC64-bit integer parsing0
[email protected]MITArray parsing0
[email protected]MITBytea decoding0
[email protected]MITDate and timestamp parsing0
[email protected]MITInterval parsing1 — archived xtend

Immutable release

One artifact across every release surface

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

Source-level documentation