How to use the Decimal128 function from bson

Find comprehensive JavaScript bson.Decimal128 code examples handpicked from public code repositorys.

36
37
38
39
40
41
42
43
44
45
},
NumberDecimal: function(s) {
  if (s === undefined) {
    s = '0';
  }
  return bson.Decimal128.fromString(s.toString());
},
NumberInt: function(s) {
  return parseInt(s, 10);
},
fork icon121
star icon761
watch icon0

+ 6 other calls in file

9
10
11
12
13
14
15
16
17
18
19
const Code = bson.Code;
const Timestamp = bson.Timestamp;
const Long = bson.Long;
const Double = bson.Double;
const Int32 = bson.Int32;
const Decimal128 = bson.Decimal128;
const TypeChecker = require('../');


describe('TypeChecker', function() {
  describe('#cast', function() {
fork icon121
star icon761
watch icon0

+ 7 other calls in file

342
343
344
345
346
347
348
349
350
351
});

context('when providing a decimal128', function() {
  it('correctly converts to NumberDecimal', function() {
    var stringified = parser.stringify({
      test: bson.Decimal128.fromString('5.5')
    });
    assert.equal(stringified, "{test: NumberDecimal('5.5')}");
  });
});
fork icon9
star icon35
watch icon0

+ 3 other calls in file

44
45
46
47
48
49
50
51
52
53
/** @type {import('bson').Code} */
module.exports.Code = BSONJS.Code;
/** @type {import('bson').DBRef} */
module.exports.DBRef = BSONJS.DBRef;
/** @type {import('bson').Decimal128} */
module.exports.Decimal128 = BSONJS.Decimal128;
/** @type {import('bson').Double} */
module.exports.Double = BSONJS.Double;
/** @type {import('bson').Int32} */
module.exports.Int32 = BSONJS.Int32;
fork icon0
star icon0
watch icon0

+ 12 other calls in file