Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-protocol

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-protocol - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

8

dist/b.js

@@ -5,3 +5,3 @@ "use strict";

const buffer_writer_1 = require("./buffer-writer");
const index_1 = require("./index");
const buffer_reader_1 = require("./buffer-reader");
const LOOPS = 1000;

@@ -11,2 +11,4 @@ let count = 0;

const writer = new buffer_writer_1.Writer();
const reader = new buffer_reader_1.BufferReader();
const buffer = Buffer.from([33, 33, 33, 33, 33, 33, 33, 0]);
const run = () => {

@@ -19,4 +21,4 @@ if (count > LOOPS) {

for (let i = 0; i < LOOPS; i++) {
index_1.serialize.describe({ type: 'P' });
index_1.serialize.describe({ type: 'S' });
reader.setBuffer(0, buffer);
reader.cstring();
}

@@ -23,0 +25,0 @@ setImmediate(run);

@@ -36,6 +36,8 @@ "use strict";

cstring() {
var start = this.offset;
var end = this.buffer.indexOf(0, start);
this.offset = end + 1;
return this.buffer.toString(this.encoding, start, end);
const start = this.offset;
let end = start;
while (this.buffer[end++] !== 0) { }
;
this.offset = end;
return this.buffer.toString(this.encoding, start, end - 1);
}

@@ -42,0 +44,0 @@ bytes(length) {

@@ -166,8 +166,4 @@ "use strict";

const len = this.reader.int32();
if (len === -1) {
fields[i] = null;
}
else if (this.mode === 'text') {
fields[i] = this.reader.string(len);
}
// a -1 for length means the value of the field is null
fields[i] = len === -1 ? null : this.reader.string(len);
}

@@ -237,4 +233,4 @@ return new messages_1.DataRowMessage(length, fields);

this.reader.setBuffer(offset, bytes);
var fields = {};
var fieldType = this.reader.string(1);
const fields = {};
let fieldType = this.reader.string(1);
while (fieldType !== '\0') {

@@ -241,0 +237,0 @@ fields[fieldType] = this.reader.cstring();

{
"name": "pg-protocol",
"version": "1.2.0",
"version": "1.2.1",
"description": "The postgres client/server binary protocol, implemented in TypeScript",

@@ -25,3 +25,3 @@ "main": "dist/index.js",

},
"gitHead": "0a90e018cde96268563c2678aa8739b7f9f6552a"
"gitHead": "da03b3f9050c85a7722413a03c199cc3bdbcf5bf"
}

@@ -5,2 +5,3 @@ // file for microbenchmarking

import { serialize } from './index'
import { BufferReader } from './buffer-reader'

@@ -12,2 +13,5 @@ const LOOPS = 1000

const reader = new BufferReader()
const buffer = Buffer.from([33, 33, 33, 33, 33, 33, 33, 0])
const run = () => {

@@ -20,4 +24,4 @@ if (count > LOOPS) {

for(let i = 0; i < LOOPS; i++) {
serialize.describe({ type: 'P'})
serialize.describe({ type: 'S'})
reader.setBuffer(0, buffer)
reader.cstring()
}

@@ -24,0 +28,0 @@ setImmediate(run)

@@ -11,2 +11,3 @@ const emptyBuffer = Buffer.allocUnsafe(0);

}
public setBuffer(offset: number, buffer: Buffer): void {

@@ -16,3 +17,4 @@ this.offset = offset;

}
public int16() {
public int16(): number {
const result = this.buffer.readInt16BE(this.offset);

@@ -22,3 +24,4 @@ this.offset += 2;

}
public byte() {
public byte(): number {
const result = this.buffer[this.offset];

@@ -28,3 +31,4 @@ this.offset++;

}
public int32() {
public int32(): number {
const result = this.buffer.readInt32BE(this.offset);

@@ -34,2 +38,3 @@ this.offset += 4;

}
public string(length: number): string {

@@ -40,8 +45,11 @@ const result = this.buffer.toString(this.encoding, this.offset, this.offset + length);

}
public cstring(): string {
var start = this.offset;
var end = this.buffer.indexOf(0, start);
this.offset = end + 1;
return this.buffer.toString(this.encoding, start, end);
const start = this.offset;
let end = start
while(this.buffer[end++] !== 0) { };
this.offset = end;
return this.buffer.toString(this.encoding, start, end - 1);
}
public bytes(length: number): Buffer {

@@ -48,0 +56,0 @@ const result = this.buffer.slice(this.offset, this.offset + length);

@@ -217,7 +217,4 @@ import { TransformOptions } from 'stream';

const len = this.reader.int32();
if (len === -1) {
fields[i] = null
} else if (this.mode === 'text') {
fields[i] = this.reader.string(len)
}
// a -1 for length means the value of the field is null
fields[i] = len === -1 ? null : this.reader.string(len)
}

@@ -294,4 +291,4 @@ return new DataRowMessage(length, fields);

this.reader.setBuffer(offset, bytes);
var fields: Record<string, string> = {}
var fieldType = this.reader.string(1)
const fields: Record<string, string> = {}
let fieldType = this.reader.string(1)
while (fieldType !== '\0') {

@@ -298,0 +295,0 @@ fields[fieldType] = this.reader.cstring()

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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