Skip to content

Commit

Permalink
use isBsonType
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Nov 20, 2024
1 parent 0f78bf1 commit 9dcada3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/cast/int32.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const isBsonType = require('../helpers/isBsonType');
const assert = require('assert');

/**
Expand All @@ -20,7 +21,7 @@ module.exports = function castInt32(val) {
return null;
}

const coercedVal = val._bsontype === 'Long' ? val.toNumber() : Number(val);
const coercedVal = isBsonType(val, 'Long') ? val.toNumber() : Number(val);

const INT32_MAX = 0x7FFFFFFF;
const INT32_MIN = -0x80000000;
Expand Down

0 comments on commit 9dcada3

Please sign in to comment.