Skip to content

Commit b467e69

Browse files
requested change 2
1 parent b3c8955 commit b467e69

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/cast/double.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const assert = require('assert');
44
const BSON = require('bson');
5+
const isBsonType = require('../helpers/isBsonType');
56

67
/**
78
* Given a value, cast it to a IEEE 754-2008 floating point, or throw an `Error` if the value
@@ -19,7 +20,7 @@ module.exports = function castDouble(val) {
1920
}
2021

2122
let coercedVal;
22-
if (val instanceof BSON.Long) {
23+
if (isBsonType(val, 'Long')) {
2324
coercedVal = val.toNumber();
2425
} else if (typeof val === 'string') {
2526
try {

lib/helpers/clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function clone(obj, options, isArrayChild) {
3232
return obj;
3333
}
3434

35-
if (obj._bsontype === 'Double') {
35+
if (isBsonType(obj, 'Double')) {
3636
return new BSON.Double(obj.value);
3737
}
3838
if (typeof obj === 'number' || typeof obj === 'string' || typeof obj === 'boolean' || typeof obj === 'bigint') {

0 commit comments

Comments
 (0)