Parse and serialize postgres composite values
npm install --save postgres-composite
yarn add postgres-composite
const { parse, serialize } = require('postgres-composite')
[...parse('(1,2,3)')]
// => ['1', '2', '3']
[...parse('(1,," 3")')]
// => ['1', null, ' 3']
[...parse('()')]
// => [null]
serialize(['1', '2', '3'])
// => '(1,2,3)'
serialize(['1', null, ' 3'])
// => '(1,," 3")'
The value must match format produced by the Postgres' composite output routine. The behavior with other formats is undefined.
Throws RangeError
on empty input.
MIT © Peter B (@boromisp)