PostgreSQL parsers · maintained compatibility

@stackline/pg-types

The public pg-types@2.2.0 parser contract, rebuilt as a dependency-free package with current ESM and TypeScript entry points.

  • v1.0.1
  • 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 xtend@4.0.2 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
pg-int8@1.0.1ISC64-bit integer parsing0
postgres-array@2.0.0MITArray parsing0
postgres-bytea@1.0.1MITBytea decoding0
postgres-date@1.0.7MITDate and timestamp parsing0
postgres-interval@1.2.0MITInterval parsing1 — archived xtend

Verified npm publication

Published from GitHub Actions with provenance

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

Source-level documentation