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

fb-watchman

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fb-watchman - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

105

bser.js

@@ -8,2 +8,3 @@ /* Copyright 2015-present Facebook, Inc.

var assert = require('assert');
var Int64 = require('node-int64');

@@ -109,3 +110,9 @@ // BSER uses the local endianness to reduce byte swapping overheads

case 8:
throw new Error("cannot represent 64 bit numbers in node");
var big = this.buf.slice(this.readOffset, this.readOffset + 8);
if (isBigEndian) {
// On a big endian system we can simply pass the buffer directly
return new Int64(big);
}
// Otherwise we need to byteswap
return new Int64(byteswap64(big));
default:

@@ -151,11 +158,26 @@ throw new Error("invalid integer size " + size);

Accumulator.prototype.writeInt = function(value) {
// For simplicity, we always write 32-bit integers
this.reserve(4);
if (isBigEndian) {
this.buf.writeInt32BE(value, this.writeOffset);
} else {
this.buf.writeInt32LE(value, this.writeOffset);
Accumulator.prototype.writeInt = function(value, size) {
this.reserve(size);
switch (size) {
case 1:
this.buf.writeInt8(value, this.writeOffset);
break;
case 2:
if (isBigEndian) {
this.buf.writeInt16BE(value, this.writeOffset);
} else {
this.buf.writeInt16LE(value, this.writeOffset);
}
break;
case 4:
if (isBigEndian) {
this.buf.writeInt32BE(value, this.writeOffset);
} else {
this.buf.writeInt32LE(value, this.writeOffset);
}
break;
default:
throw new Error("unsupported integer size " + size);
}
this.writeOffset += 4;
this.writeOffset += size;
}

@@ -190,2 +212,6 @@

var MAX_INT8 = 127;
var MAX_INT16 = 32768;
var MAX_INT32 = 2147483648;
function BunserBuf() {

@@ -425,2 +451,45 @@ EE.call(this);

// Byteswap an arbitrary buffer, flipping from one endian
// to the other, returning a new buffer with the resultant data
function byteswap64(buf) {
var swap = new Buffer(buf.length);
for (var i = 0; i < buf.length; i++) {
swap[i] = buf[buf.length -1 - i];
}
return swap;
}
function dump_int64(buf, val) {
// Get the raw bytes. The Int64 buffer is big endian
var be = val.toBuffer();
if (isBigEndian) {
// We're a big endian system, so the buffer is exactly how we
// want it to be
buf.writeByte(BSER_INT64);
buf.append(be);
return;
}
// We need to byte swap to get the correct representation
var le = byteswap64(be);
buf.writeByte(BSER_INT64);
buf.append(le);
}
function dump_int(buf, val) {
var abs = Math.abs(val);
if (abs <= MAX_INT8) {
buf.writeByte(BSER_INT8);
buf.writeInt(val, 1);
} else if (abs <= MAX_INT16) {
buf.writeByte(BSER_INT16);
buf.writeInt(val, 2);
} else if (abs <= MAX_INT32) {
buf.writeByte(BSER_INT32);
buf.writeInt(val, 4);
} else {
dump_int64(buf, new Int64(val));
}
}
function dump_any(buf, val) {

@@ -434,4 +503,3 @@ switch (typeof(val)) {

buf.writeByte(BSER_STRING);
buf.writeByte(BSER_INT32);
buf.writeInt(Buffer.byteLength(val));
dump_int(buf, Buffer.byteLength(val));
buf.append(val);

@@ -447,6 +515,9 @@ return;

}
if (val instanceof Int64) {
dump_int64(buf, val);
return;
}
if (Array.isArray(val)) {
buf.writeByte(BSER_ARRAY);
buf.writeByte(BSER_INT32);
buf.writeInt(val.length);
dump_int(buf, val.length);
for (var i = 0; i < val.length; ++i) {

@@ -459,4 +530,3 @@ dump_any(buf, val[i]);

var keys = Object.keys(val);
buf.writeByte(BSER_INT32);
buf.writeInt(keys.length);
dump_int(buf, keys.length);
for (var i = 0; i < keys.length; ++i) {

@@ -480,4 +550,5 @@ var key = keys[i];

buf.writeByte(1);
// Reserve room for an int32 to hold our PDU length
buf.writeByte(BSER_INT32);
buf.writeInt(0); // We'll come back and fill this in at the end
buf.writeInt(0, 4); // We'll come back and fill this in at the end

@@ -490,3 +561,3 @@ dump_any(buf, val);

buf.writeOffset = 3; // The length value to fill in
buf.writeInt(len);
buf.writeInt(len, 4); // write the length in the space we reserved
buf.writeOffset = off;

@@ -493,0 +564,0 @@

3

package.json
{
"name": "fb-watchman",
"version": "1.0.0",
"version": "1.1.0",
"description": "Bindings for the Watchman file watching service",

@@ -14,2 +14,3 @@ "main": "index.js",

"dependencies": {
"node-int64": "0.4.0"
},

@@ -16,0 +17,0 @@ "keywords": [

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