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

hadron-type-checker

Package Overview
Dependencies
Maintainers
46
Versions
497
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hadron-type-checker - npm Package Compare versions

Comparing version 4.0.4 to 5.0.0

.github/ISSUE_TEMPLATE/bug_report.md

4

index.js

@@ -1,3 +0,1 @@

'use strict';
module.exports = require('./lib/type-checker');
module.exports = require('./src/type-checker');

@@ -7,3 +7,3 @@ {

"homepage": "https://github.com/mongodb-js/hadron-type-checker",
"version": "4.0.4",
"version": "5.0.0",
"repository": {

@@ -19,37 +19,15 @@ "type": "git",

"ci": "npm test",
"fmt": "mongodb-js-fmt ./*.js ./test/*.js",
"test": "mocha --recursive",
"check": "mongodb-js-precommit",
"prepublish": "babel ./src --out-dir ./lib",
"pretest": "babel ./src --out-dir ./lib"
"test": "mocha",
"check": "mongodb-js-precommit"
},
"precommit": [
"check"
],
"dependencies": {
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.5.2",
"bson": "^1.0.1",
"lodash.has": "^4.4.0",
"lodash.includes": "^4.3.0",
"lodash.isarray": "^4.0.0",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.4",
"lodash.isstring": "^4.0.1",
"lodash.keys": "^4.2.0",
"lodash.tonumber": "^4.0.2",
"lodash.tostring": "^4.1.3",
"lodash.without": "^4.4.0"
"bson": "^4.0.3",
"lodash": "^4.17.15"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"chai": "^3.4.1",
"eslint-config-mongodb-js": "^2.2.0",
"mocha": "^3.1.2",
"mongodb-js-fmt": "^0.0.3",
"mongodb-js-precommit": "^0.2.9",
"pre-commit": "^1.1.2"
"chai": "^4.2.0",
"eslint-config-mongodb-js": "^5.0.3",
"mocha": "^7.0.1",
"mongodb-js-precommit": "^2.1.0"
}
}

@@ -1,26 +0,29 @@

'use strict';
const {
isPlainObject,
isArray,
isString,
isNumber,
hasIn,
keys,
without,
toNumber,
toString,
includes,
} = require('lodash');
const isPlainObject = require('lodash.isplainobject');
const isArray = require('lodash.isarray');
const isString = require('lodash.isstring');
const isNumber = require('lodash.isnumber');
const has = require('lodash.has');
const keys = require('lodash.keys');
const without = require('lodash.without');
const toNumber = require('lodash.tonumber');
const toString = require('lodash.tostring');
const includes = require('lodash.includes');
const bson = require('bson');
const MinKey = bson.MinKey;
const MaxKey = bson.MaxKey;
const Long = bson.Long;
const Double = bson.Double;
const Int32 = bson.Int32;
const Decimal128 = bson.Decimal128;
const Binary = bson.Binary;
const BSONRegExp = bson.BSONRegExp;
const Code = bson.Code;
const Symbol = bson.Symbol;
const Timestamp = bson.Timestamp;
const {
ObjectId,
MinKey,
MaxKey,
Long,
Double,
Int32,
Decimal128,
Binary,
BSONRegExp,
Code,
BSONSymbol,
Timestamp,
BSONMap
} = require('bson');
/**

@@ -72,3 +75,3 @@ * The object string.

*/
const BSON_INT32_MAX = 0x7FFFFFFF;
const BSON_INT32_MAX = 0x7fffffff;

@@ -81,3 +84,3 @@ /**

const BSON_INT64_MAX = Math.pow(2, 63) - 1;
const BSON_INT64_MIN = -(BSON_INT64_MAX);
const BSON_INT64_MIN = -BSON_INT64_MAX;

@@ -92,8 +95,3 @@ /**

*/
const NUMBER_TYPES = [
'Long',
'Int32',
'Double',
'Decimal128'
];
const NUMBER_TYPES = ['Long', 'Int32', 'Double', 'Decimal128'];

@@ -149,3 +147,3 @@ const toDate = (object) => {

}
return [ object ];
return [object];
};

@@ -190,6 +188,6 @@

*/
if (has(object, BSON_TYPE) && includes(NUMBER_TYPES, object._bsontype)) {
if (hasIn(object, BSON_TYPE) && includes(NUMBER_TYPES, object._bsontype)) {
object = object._bsontype === LONG ? object.toNumber() : object.valueOf();
}
return Decimal128.fromString(String(object));
return Decimal128.fromString('' + object);
};

@@ -199,21 +197,21 @@

if (!isString(object) || object === '') {
return new bson.ObjectID();
return new ObjectId();
}
return bson.ObjectID.createFromHexString(object);
return ObjectId.createFromHexString(object);
};
const toBinary = (object) => {
return new Binary(String(object), Binary.SUBTYPE_DEFAULT);
return new Binary('' + object, Binary.SUBTYPE_DEFAULT);
};
const toRegex = (object) => {
return new BSONRegExp(String(object));
return new BSONRegExp('' + object);
};
const toCode = (object) => {
return new Code(String(object), {});
return new Code('' + object, {});
};
const toSymbol = (object) => {
return new Symbol(String(object));
return new BSONSymbol('' + object);
};

@@ -226,2 +224,6 @@

const toMap = (object) => {
return new BSONMap(object);
};
/**

@@ -231,21 +233,22 @@ * The functions to cast to a type.

const CASTERS = {
'Array': toArray,
'Binary': toBinary,
'Boolean': toBoolean,
'Code': toCode,
'Date': toDate,
'Decimal128': toDecimal128,
'Double': toDouble,
'Int32': toInt32,
'Int64': toInt64,
'MaxKey': toMaxKey,
'MinKey': toMinKey,
'Null': toNull,
'Object': toObject,
'ObjectId': toObjectID,
'BSONRegexp': toRegex,
'String': toString,
'Symbol': toSymbol,
'Timestamp': toTimestamp,
'Undefined': toUndefined
Array: toArray,
Binary: toBinary,
Boolean: toBoolean,
Code: toCode,
Date: toDate,
Decimal128: toDecimal128,
Double: toDouble,
Int32: toInt32,
Int64: toInt64,
MaxKey: toMaxKey,
MinKey: toMinKey,
Null: toNull,
Object: toObject,
ObjectId: toObjectID,
BSONRegexp: toRegex,
String: toString,
BSONSymbol: toSymbol,
BSONMap: toMap,
Timestamp: toTimestamp,
Undefined: toUndefined
};

@@ -307,3 +310,2 @@

class TypeChecker {
/**

@@ -334,2 +336,11 @@ * Cast the provided object to the desired type.

type(object) {
if (hasIn(object, BSON_TYPE)) {
if (object._bsontype === LONG) {
return INT_64;
}
if (object._bsontype === OBJECT_ID) {
return 'ObjectId';
}
return object._bsontype;
}
if (isNumber(object)) {

@@ -344,11 +355,2 @@ return numberToBsonType(object);

}
if (has(object, BSON_TYPE)) {
if (object._bsontype === LONG) {
return INT_64;
}
if (object._bsontype === OBJECT_ID) {
return 'ObjectId';
}
return object._bsontype;
}
return Object.prototype.toString.call(object).replace(MATCH, '$1');

@@ -355,0 +357,0 @@ }

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