New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pg-copy-streams-binary

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-copy-streams-binary - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

6

lib/deparser.js

@@ -27,4 +27,2 @@ /**

this.COPYSignature = new Buffer([0x50, 0x47, 0x43, 0x4f, 0x50, 0x59, 0x0a, 0xff, 0x0d, 0x0a, 0x00]);
this.mapping = options.mapping || false;
}

@@ -37,3 +35,3 @@

var buf = new BufferPut();
var fieldCount = this.mapping ? this.mapping.length : chunk.length;
var fieldCount = chunk.length;

@@ -59,3 +57,3 @@ // See [1] - File Header Section

for (i=0; i<fieldCount; i++) {
vec = this.mapping ? this.mapping[i](chunk) : chunk[i];
vec = chunk[i];
deparse(buf, vec.type, vec.value);

@@ -62,0 +60,0 @@ }

{
"name": "pg-copy-streams-binary",
"version": "1.0.2",
"version": "1.1.0",
"description": "Streams for parsing and deparsing the COPY binary format",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -188,4 +188,12 @@ ## pg-copy-streams-binary

## API for Deparser
## API for deparser
the deparser is usually used without arguments. It is a Transform Stream (always in object mode) that receives a stream of arrays, and outputs their PostgreSQL binary representation.
Each array is a sequence of { type:.. , value: ..} pairs, where `type` is a PostgreSQL type (cf section supported types) and `value` is the value that need to be deparsed.
Currently, make sure sure value is not the javascript `undefined` because this case is not handled in the deparser. The value can be `null` but don't forget that the target table field should be nullable or the database will complain.
Usually, you would want to use a through2 stream to prepare the arrays, and pipe this into the deparser.
### options.COPY_sendHeader

@@ -203,10 +211,3 @@

### options.mapping
default: false
By default, the Deparser expects a stream of arrays. Each array consists of `{ type: type, value: value }` elements. The length of the array MUST be equal to the number of fields in your target database table. The types MUST be identical to the types of the fields in the database (cf the "currently supported types")
This `mapping` option can be used to transform an stream of objects into such an array. mapping MUST be an array of Function elements. The prototype of the function is `function(row)`. The function can do what it wants with the row and output the necessary `{ type: type, value: value }`
## API for Parser

@@ -213,0 +214,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc