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

bsonview

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

bsonview - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

lib/decimal-view.js

4

index.js

@@ -1,4 +0,2 @@

const {
ArrayView, BooleanView, StringView, TypeView,
} = require('structurae');
const { ArrayView, BooleanView, StringView, TypeView } = require('structurae');
const ObjectIdView = require('./lib/objectid-view');

@@ -5,0 +3,0 @@ const DateView = require('./lib/date-view');

@@ -17,4 +17,4 @@ const { MapView } = require('structurae');

const end = view.getUint32(startOffset + 4, true);
object[field] = fieldStart === end ? null
: View.toBSON(view, start + fieldStart, end - fieldStart);
object[field] =
fieldStart === end ? null : View.toBSON(view, start + fieldStart, end - fieldStart);
}

@@ -21,0 +21,0 @@ return object;

@@ -1,4 +0,2 @@

const {
ObjectView, ArrayView, BooleanView, StringView, ArrayViewMixin,
} = require('structurae');
const { ObjectView, ArrayView, BooleanView, StringView, ArrayViewMixin } = require('structurae');
const TypeViewMixin = require('./type-view-mixin');

@@ -12,2 +10,3 @@ const ObjectIdView = require('./objectid-view');

const TimestampView = require('./timestamp-view');
const DecimalView = require('./decimal-view');

@@ -23,5 +22,5 @@ const supportedBSONTypes = {

0x09: 1, // UTC datetime int64
0x0A: 1, // Null
0x0B: 1, // RegExp
0x0D: 1, // JavaScript code
0x0a: 1, // Null
0x0b: 1, // RegExp
0x0d: 1, // JavaScript code
0x10: 1, // int32

@@ -57,10 +56,10 @@ 0x11: 1, // Timestamp uint64

static hasBSONLength(type) {
return (type > 0x01 && type < 0x06) || (type > 0x0C && type < 0x10);
return (type > 0x01 && type < 0x06) || (type > 0x0c && type < 0x10);
}
static getBSONInt32(bson, index) {
let length = 0xFF & bson[index];
length |= (0xFF & bson[index + 1]) << 8;
length |= (0xFF & bson[index + 2]) << 16;
length |= (0xFF & bson[index + 3]) << 24;
let length = 0xff & bson[index];
length |= (0xff & bson[index + 1]) << 8;
length |= (0xff & bson[index + 2]) << 16;
length |= (0xff & bson[index + 3]) << 24;
return length;

@@ -81,3 +80,3 @@ }

case 0x05: // binary
case 0x0D: // JavaScript code
case 0x0d: // JavaScript code
return this.getBSONInt32(bson, startIndex);

@@ -88,3 +87,3 @@ case 0x07: // ObjectID

return 1;
case 0x0B: // RegExp
case 0x0b: // RegExp
const petternEnd = bson.indexOf(0, startIndex);

@@ -122,3 +121,4 @@ return bson.indexOf(0, petternEnd + 1) - startIndex + 1;

let SubView = View;
if (itemLength) { // it's an array
if (itemLength) {
// it's an array
start = offset + index * itemLength;

@@ -134,5 +134,5 @@ SubView = View.View;

SubView = fieldOptions.View;
const hasTypeConflict = ((elementType === 0x03
&& !(SubView.prototype instanceof ObjectView))
|| (elementType === 0x04 && !(SubView.prototype instanceof ArrayView)));
const hasTypeConflict =
(elementType === 0x03 && !(SubView.prototype instanceof ObjectView)) ||
(elementType === 0x04 && !(SubView.prototype instanceof ArrayView));
hasValue = !!valueLength && !hasTypeConflict;

@@ -142,4 +142,12 @@ }

if (hasValue) {
this.writeBSONtoView(bson, elementType, valueStart,
valueLength, view, start, fieldLength, SubView);
this.writeBSONtoView(
bson,
elementType,
valueStart,
valueLength,
view,
start,
fieldLength,
SubView,
);
}

@@ -156,8 +164,14 @@ index++;

case 0x03: // document
this.readBSONObject(bson, valueStart, valueStart + valueLength,
view, start, View);
this.readBSONObject(bson, valueStart, valueStart + valueLength, view, start, View);
break;
case 0x04: // array
this.readBSONObject(bson, valueStart, valueStart + valueLength,
view, start, View, View.itemLength);
this.readBSONObject(
bson,
valueStart,
valueStart + valueLength,
view,
start,
View,
View.itemLength,
);
break;

@@ -279,3 +293,6 @@ default:

},
// todo decimal
decimal128() {
return DecimalView;
},
};

@@ -282,0 +299,0 @@

@@ -1,2 +0,1 @@

/** Lookup tables to speed up ObjectId string <-> binary conversions. */

@@ -49,5 +48,6 @@ const hexToStringTable = [];

while (i < 24) {
objectView.setUint8(start + n++,
(stringToHexTable[string.charCodeAt(i++)] << 4)
| stringToHexTable[string.charCodeAt(i++)]);
objectView.setUint8(
start + n++,
(stringToHexTable[string.charCodeAt(i++)] << 4) | stringToHexTable[string.charCodeAt(i++)],
);
}

@@ -54,0 +54,0 @@ return objectView;

@@ -15,3 +15,4 @@ const { StringView } = require('structurae');

static from(arrayLike, mapFn, thisArg, length) {
if (arrayLike && Object.prototype.toString.call(arrayLike) !== '[object RegExp]') return super.from(arrayLike, mapFn, thisArg);
if (arrayLike && Object.prototype.toString.call(arrayLike) !== '[object RegExp]')
return super.from(arrayLike, mapFn, thisArg);
const string = `${arrayLike.source}${ZERO_CHAR}${arrayLike.flags}`;

@@ -18,0 +19,0 @@ return super.from(string, mapFn, thisArg, length);

{
"name": "bsonview",
"version": "0.8.0",
"version": "0.9.0",
"description": "Schema-based BSON using structurae's ObjectView binary protocol.",

@@ -43,4 +43,5 @@ "main": "index.js",

"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-import": "^2.20.2",
"jest": "^25.2.7",
"jest": "^25.3.0",
"json-schema-faker": "^0.5.0-rcv.24"

@@ -68,3 +69,47 @@ },

}
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all"
},
"eslintConfig": {
"extends": [
"airbnb-base",
"prettier"
],
"env": {
"node": true,
"jest": true
},
"globals": {
"globalThis": false
},
"rules": {
"max-classes-per-file": 1,
"no-bitwise": 0,
"no-plusplus": 0,
"no-continue": 0,
"no-restricted-syntax": 1,
"no-nested-ternary": 1,
"no-labels": 1,
"no-param-reassign": [
2,
{
"props": false
}
],
"valid-jsdoc": [
2,
{
"prefer": {
"return": "returns"
},
"requireReturnDescription": false,
"requireParamDescription": false
}
],
"import/no-extraneous-dependencies": 1
}
}
}
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