Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
postgres-array
Advanced tools
The postgres-array package is a utility for parsing and serializing arrays in the format used by PostgreSQL. It allows Node.js applications to easily convert between JavaScript arrays and the string format used by PostgreSQL for array columns.
Parsing PostgreSQL array strings to JavaScript arrays
This feature allows you to convert a PostgreSQL array string into a JavaScript array. It is useful when you fetch data from a PostgreSQL database and want to work with it in JavaScript.
const parse = require('postgres-array').parse;
let postgresArray = '{1,2,3,4}';
let jsArray = parse(postgresArray);
// jsArray is now [1, 2, 3, 4]
Serializing JavaScript arrays to PostgreSQL array strings
This feature allows you to convert a JavaScript array into a PostgreSQL array string. It is useful when you need to insert or update data in a PostgreSQL database that requires the array format.
const stringify = require('postgres-array').stringify;
let jsArray = [1, 2, 3, 4];
let postgresArray = stringify(jsArray);
// postgresArray is now '{1,2,3,4}'
pg-promise is a PostgreSQL interface for Node.js. It includes robust support for parameterized queries, named parameters, and automatic conversion of JavaScript objects to PostgreSQL hstore format. It provides more comprehensive database interaction functionalities compared to postgres-array, which focuses solely on array conversion.
Parse postgres array columns
$ npm install --save postgres-array
var postgresArray = require('postgres-array')
postgresArray.parse('{1,2,3}', (value) => parseInt(value, 10))
//=> [1, 2, 3]
parse(input, [transform])
-> array
Required
Type: string
A Postgres array string.
Type: function
Default: identity
A function that transforms non-null values inserted into the array.
MIT © Ben Drucker
FAQs
Parse postgres array columns
The npm package postgres-array receives a total of 7,701,677 weekly downloads. As such, postgres-array popularity was classified as popular.
We found that postgres-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.