hadron-type-checker
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/hadron-type-checker", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"repository": { | ||
@@ -29,5 +29,5 @@ "type": "git", | ||
"eslint-config-mongodb-js": "^5.0.3", | ||
"mocha": "^7.0.1", | ||
"mocha": "^8.0.1", | ||
"mongodb-js-precommit": "^2.1.0" | ||
} | ||
} |
@@ -162,7 +162,20 @@ const { | ||
} | ||
const number = toNumber(object); | ||
if (number >= BSON_INT64_MIN && number <= BSON_INT64_MAX) { | ||
return Long.fromNumber(number); | ||
// when casting from int32 object(this will have object.value) or literal | ||
// (it will a typeof number) we can safely create object fromNumber, as it | ||
// will not be greater than JS's max value | ||
if (object.value || typeof object === 'number') { | ||
return Long.fromNumber(number); | ||
} else if (typeof object === 'object') { | ||
// to make sure we are still displaying Very Large numbers properly, convert | ||
// the current 'object' to a string | ||
return Long.fromString(object.toString()); | ||
} | ||
return Long.fromString(object); | ||
} | ||
throw new Error(`Value ${number} is outside the valid Int64 range`); | ||
throw new Error(`Value ${object.toString()} is outside the valid Int64 range`); | ||
}; | ||
@@ -186,3 +199,3 @@ | ||
if (hasIn(object, BSON_TYPE) && includes(NUMBER_TYPES, object._bsontype)) { | ||
object = object._bsontype === LONG ? object.toNumber() : object.valueOf(); | ||
object = object._bsontype === LONG ? object.toString() : object.valueOf(); | ||
} | ||
@@ -189,0 +202,0 @@ return Decimal128.fromString('' + object); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22541
332
1