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

ferrum-db-client

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ferrum-db-client - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

78

dist/client.js

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

if (this.pending.has(id)) {
this.pending.get(id)(msgBuffer.slice(4, msgSize));
this.pending.get(id)(Buffer.from(msgBuffer.slice(4, msgSize)));
this.pending.delete(id);

@@ -488,42 +488,48 @@ }

const len = br.readInt();
console.log(`Fetched ${len} bytes from DB`);
const result = Buffer.from(br.readBytes(len));
let decompressed;
let decodedValue;
switch (this.compression) {
case "gzip":
decompressed = await gunzipPromise(result);
break;
default:
decompressed = result;
break;
}
if (this.encoding === "bson") {
if (decompressed.length > bsonBufferSize) {
bson_1.setInternalBufferSize(decompressed.length);
bsonBufferSize = decompressed.length;
console.log(`${key} read ${len} bytes from DB`);
try {
const result = Buffer.from(br.readBytes(len));
let decompressed;
let decodedValue;
switch (this.compression) {
case "gzip":
decompressed = await gunzipPromise(result);
break;
default:
decompressed = result;
break;
}
decodedValue = bson_1.deserialize(decompressed);
}
else if (this.encoding === "json") {
try {
decodedValue = JSON.parse(decompressed.toString("utf8"));
if (this.encoding === "bson") {
if (decompressed.length > bsonBufferSize) {
bson_1.setInternalBufferSize(decompressed.length);
bsonBufferSize = decompressed.length;
}
decodedValue = bson_1.deserialize(decompressed);
}
catch (e) {
throw new Error(`Failed to decode JSON for key ${key}. ${decompressed.toString("utf8")}`);
else if (this.encoding === "json") {
try {
decodedValue = JSON.parse(decompressed.toString("utf8"));
}
catch (e) {
throw new Error(`Failed to decode JSON for key ${key}. ${decompressed.toString("utf8")}`);
}
}
else if (this.encoding === "ndjson") {
decodedValue = decompressed
.toString("utf8")
.split("\n")
.map((e) => JSON.parse(e));
}
else if (this.encoding === "string") {
decodedValue = decompressed.toString("utf8");
}
else {
decodedValue = decompressed;
}
return decodedValue;
}
else if (this.encoding === "ndjson") {
decodedValue = decompressed
.toString("utf8")
.split("\n")
.map((e) => JSON.parse(e));
catch (e) {
console.error(`Failed to get ${key} from ${this.indexKey}`);
throw e;
}
else if (this.encoding === "string") {
decodedValue = decompressed.toString("utf8");
}
else {
decodedValue = decompressed;
}
return decodedValue;
}

@@ -530,0 +536,0 @@ }

{
"name": "ferrum-db-client",
"version": "0.0.2",
"version": "0.0.3",
"main": "dist/client.js",

@@ -5,0 +5,0 @@ "typings": "dist/client.d.ts",

@@ -157,3 +157,5 @@ import { Socket } from "net";

if (this.pending.has(id)) {
this.pending.get(id)(msgBuffer.slice(4, msgSize));
this.pending.get(id)(
Buffer.from(msgBuffer.slice(4, msgSize))
);
this.pending.delete(id);

@@ -666,44 +668,51 @@ }

const len = br.readInt();
console.log(`Fetched ${len} bytes from DB`);
const result = Buffer.from(br.readBytes(len));
let decompressed: Buffer;
let decodedValue: any;
console.log(`${key} read ${len} bytes from DB`);
try {
const result = Buffer.from(br.readBytes(len));
let decompressed: Buffer;
let decodedValue: any;
switch (this.compression) {
case "gzip":
decompressed = await gunzipPromise(result);
break;
default:
decompressed = result;
break;
}
switch (this.compression) {
case "gzip":
decompressed = await gunzipPromise(result);
break;
default:
decompressed = result;
break;
}
if (this.encoding === "bson") {
if (decompressed.length > bsonBufferSize) {
setInternalBufferSize(decompressed.length);
bsonBufferSize = decompressed.length;
if (this.encoding === "bson") {
if (decompressed.length > bsonBufferSize) {
setInternalBufferSize(decompressed.length);
bsonBufferSize = decompressed.length;
}
decodedValue = deserialize(decompressed);
} else if (this.encoding === "json") {
try {
decodedValue = JSON.parse(
decompressed.toString("utf8")
);
} catch (e) {
throw new Error(
`Failed to decode JSON for key ${key}. ${decompressed.toString(
"utf8"
)}`
);
}
} else if (this.encoding === "ndjson") {
decodedValue = decompressed
.toString("utf8")
.split("\n")
.map((e) => JSON.parse(e));
} else if (this.encoding === "string") {
decodedValue = decompressed.toString("utf8");
} else {
decodedValue = decompressed;
}
decodedValue = deserialize(decompressed);
} else if (this.encoding === "json") {
try {
decodedValue = JSON.parse(decompressed.toString("utf8"));
} catch (e) {
throw new Error(
`Failed to decode JSON for key ${key}. ${decompressed.toString(
"utf8"
)}`
);
}
} else if (this.encoding === "ndjson") {
decodedValue = decompressed
.toString("utf8")
.split("\n")
.map((e) => JSON.parse(e));
} else if (this.encoding === "string") {
decodedValue = decompressed.toString("utf8");
} else {
decodedValue = decompressed;
return decodedValue;
} catch (e) {
console.error(`Failed to get ${key} from ${this.indexKey}`);
throw e;
}
return decodedValue;
}

@@ -710,0 +719,0 @@ }

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