UNPKG

1.46 kBJavaScriptView Raw
1var BSON = require('./lib/bson/bson'),
2 Binary = require('./lib/bson/binary'),
3 Code = require('./lib/bson/code'),
4 DBRef = require('./lib/bson/db_ref'),
5 Decimal128 = require('./lib/bson/decimal128'),
6 Double = require('./lib/bson/double'),
7 Int32 = require('./lib/bson/int_32'),
8 Long = require('./lib/bson/long'),
9 Map = require('./lib/bson/map'),
10 MaxKey = require('./lib/bson/max_key'),
11 MinKey = require('./lib/bson/min_key'),
12 ObjectId = require('./lib/bson/objectid'),
13 BSONRegExp = require('./lib/bson/regexp'),
14 Symbol = require('./lib/bson/symbol'),
15 Timestamp = require('./lib/bson/timestamp');
16
17// BSON MAX VALUES
18BSON.BSON_INT32_MAX = 0x7fffffff;
19BSON.BSON_INT32_MIN = -0x80000000;
20
21BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
22BSON.BSON_INT64_MIN = -Math.pow(2, 63);
23
24// JS MAX PRECISE VALUES
25BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
26BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
27
28// Add BSON types to function creation
29BSON.Binary = Binary;
30BSON.Code = Code;
31BSON.DBRef = DBRef;
32BSON.Decimal128 = Decimal128;
33BSON.Double = Double;
34BSON.Int32 = Int32;
35BSON.Long = Long;
36BSON.Map = Map;
37BSON.MaxKey = MaxKey;
38BSON.MinKey = MinKey;
39BSON.ObjectId = ObjectId;
40BSON.ObjectID = ObjectId;
41BSON.BSONRegExp = BSONRegExp;
42BSON.Symbol = Symbol;
43BSON.Timestamp = Timestamp;
44
45// Return the BSON
46module.exports = BSON;