Registry / database / pg-parse-float

pg-parse-float

JSON →
library0.0.1jsnpmunverified

Small utility to restore JavaScript parseFloat behavior to node-postgres (pg), converting float4, float8, and numeric columns to JavaScript floats. Version 0.0.1 is stable, with no active development. It serves as a reference for building custom type parsers. Differentiates itself as a minimal, dependency-free patch for node-postgres users who want floats instead of strings for numeric types.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The library is CommonJS only and should be called as a function with the pg module as argument.

const pgParseFloat = require('pg-parse-float'); pgParseFloat(pg);

Shows how to require and invoke pg-parse-float to patch node-postgres, then query a float column and receive a JavaScript number.

const pg = require('pg'); const pgParseFloat = require('pg-parse-float'); pgParseFloat(pg); const client = new pg.Client({ host: 'localhost', database: 'test' }); client.connect(); client.query('SELECT 1.5::float4 AS f', (err, result) => { if (err) throw err; console.log(result.rows[0].f); // 1.5 (number) client.end(); });
Debug
Known footguns
gotchaMust pass the same pg module instance that you use for queries. If you require pg separately inside other modules, those will not be patched.
gotchaThis overrides the default parser for float4, float8, and numeric types. If you rely on string representations (e.g., for precise numeric handling), floats may lose precision.
deprecatedThe package has not been updated since 2014 and is not compatible with modern node-postgres versions that use ES modules or TypeScript.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources