Socket
Socket
Sign inDemoInstall

deepak

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deepak - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

lib/countkeys.js

14

lib/index.js

@@ -29,4 +29,5 @@

Deepak = (function() {
function Deepak(tuple) {
this.tuple = tuple;
function Deepak(fdb) {
this.fdb = fdb;
this.db = this.fdb.open();
}

@@ -38,5 +39,5 @@

Deepak.prototype.packArrayValues = require('./packarrayvalues');
Deepak.prototype.packArray = require('./packarray');
Deepak.prototype.unpackArrayValues = require('./unpackarrayvalues');
Deepak.prototype.unpackArray = require('./unpackarray');

@@ -51,3 +52,6 @@ return Deepak;

if (instance === null) {
instance = new Deepak(fdb.tuple);
if (fdb == null) {
fdb = require('fdb').apiVersion(200);
}
instance = new Deepak(fdb);
}

@@ -54,0 +58,0 @@ return instance;

(function() {
var packArray, packNumber, packObject, surreal;
var packBuffer, packUIntByte, surreal;

@@ -30,28 +30,24 @@ surreal = require('surreal');

packNumber = function(deepak, val) {
if (val % 1 === 0) {
return deepak.tuple.pack([2, val]);
} else {
return deepak.tuple.pack([3, new Buffer('' + val, 'ascii')]);
packUIntByte = function(val, buf) {
if (!buf) {
buf = new Buffer(1);
}
buf.writeUInt8(val, 0);
return buf;
};
packObject = function(deepak, val) {
if (val === null) {
return deepak.tuple.pack([5]);
} else if (val instanceof Date) {
return deepak.tuple.pack([6, val.getTime()]);
} else if (val instanceof Array) {
return deepak.tuple.pack([7, packArray(deepak, val)]);
} else if (val instanceof Object) {
return deepak.tuple.pack([8, new Buffer(surreal.serialize(val), 'ascii')]);
} else {
throw new Error("the packValue function only accepts string, number, boolean, date, array and object");
packBuffer = function(typeCode, buf) {
var len, packedVal;
len = 1;
if (buf) {
len += buf.length;
}
packedVal = new Buffer(len);
packUIntByte(typeCode, packedVal);
if (buf) {
buf.copy(packedVal, 1);
}
return packedVal;
};
packArray = function(deepak, val) {
return deepak.tuple.pack(deepak.packArrayValues(val));
};
module.exports = function(val) {

@@ -63,11 +59,26 @@ if (val === '\xff') {

case 'undefined':
return this.tuple.pack([]);
return packBuffer(0);
case 'string':
return this.tuple.pack([1, new Buffer(val, 'ascii')]);
return packBuffer(1, new Buffer(val, 'ascii'));
case 'number':
return packNumber(this, val);
if (val % 1 === 0) {
return packBuffer(2, new Buffer('' + val, 'ascii'));
} else {
return packBuffer(3, new Buffer('' + val, 'ascii'));
}
break;
case 'boolean':
return this.tuple.pack([4, (val ? 1 : 0)]);
return packBuffer(4, packUIntByte(val ? 1 : 0));
default:
return packObject(this, val);
if (val === null) {
return packBuffer(5);
} else if (val instanceof Date) {
return packBuffer(6, new Buffer('' + val.getTime(), 'ascii'));
} else if (val instanceof Array) {
return packBuffer(7, this.fdb.tuple.pack(this.packArray(val)));
} else if (val instanceof Object) {
return packBuffer(8, new Buffer(surreal.serialize(val), 'ascii'));
} else {
throw new Error("the packValue function only accepts string, number, boolean, date, array and object");
}
}

@@ -74,0 +85,0 @@ };

(function() {
var surreal, unpackArray;
var surreal;

@@ -30,10 +30,4 @@ surreal = require('surreal');

unpackArray = function(deepak, val) {
var arr;
arr = deepak.tuple.unpack(val);
return deepak.unpackArrayValues(arr);
};
module.exports = function(val) {
var type, unpacked;
var type;
if (!val) {

@@ -45,7 +39,6 @@ return null;

}
unpacked = this.tuple.unpack(val);
type = unpacked[0];
val = unpacked[1];
type = val.slice(0, 1).readUInt8(0);
val = val.slice(1);
switch (type) {
case void 0:
case 0:
break;

@@ -55,13 +48,13 @@ case 1:

case 2:
return val;
return parseInt(val.toString('ascii'), 10);
case 3:
return parseFloat(val.toString('ascii'));
return parseFloat(val.toString('ascii'), 10);
case 4:
return val === 1;
return val.readUInt8(0) === 1;
case 5:
return null;
case 6:
return new Date(val);
return new Date(parseInt(val.toString('ascii'), 10));
case 7:
return unpackArray(this, val);
return this.unpackArray(this.fdb.tuple.unpack(val));
case 8:

@@ -68,0 +61,0 @@ return surreal.deserialize(val.toString('ascii'));

{
"name": "deepak",
"description": "Deep packer & unpacker for strongly typed high performance FoundationDB key and value data",
"version": "0.0.7",
"version": "0.1.0",
"contributors": [

@@ -6,0 +6,0 @@ {

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