bson 4.6.5 → 5.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bson.d.ts +208 -267
- package/lib/bson.bundle.js +4033 -0
- package/lib/bson.bundle.js.map +1 -0
- package/lib/bson.cjs +4028 -0
- package/lib/bson.cjs.map +1 -0
- package/lib/bson.mjs +4002 -0
- package/lib/bson.mjs.map +1 -0
- package/package.json +49 -61
- package/src/binary.ts +235 -37
- package/src/bson.ts +43 -129
- package/src/code.ts +24 -14
- package/src/constants.ts +28 -0
- package/src/db_ref.ts +13 -8
- package/src/decimal128.ts +31 -25
- package/src/double.ts +7 -5
- package/src/error.ts +0 -2
- package/src/extended_json.ts +148 -148
- package/src/index.ts +19 -0
- package/src/int_32.ts +7 -5
- package/src/long.ts +16 -16
- package/src/max_key.ts +6 -6
- package/src/min_key.ts +6 -6
- package/src/objectid.ts +41 -74
- package/src/parser/calculate_size.ts +39 -63
- package/src/parser/deserializer.ts +47 -113
- package/src/parser/serializer.ts +234 -341
- package/src/parser/utils.ts +1 -99
- package/src/regexp.ts +16 -5
- package/src/symbol.ts +7 -5
- package/src/timestamp.ts +62 -27
- package/src/utils/byte_utils.ts +61 -0
- package/src/utils/node_byte_utils.ts +141 -0
- package/src/utils/web_byte_utils.ts +190 -0
- package/src/uuid_utils.ts +15 -15
- package/bower.json +0 -26
- package/dist/bson.browser.esm.js +0 -7471
- package/dist/bson.browser.esm.js.map +0 -1
- package/dist/bson.browser.umd.js +0 -7538
- package/dist/bson.browser.umd.js.map +0 -1
- package/dist/bson.bundle.js +0 -7537
- package/dist/bson.bundle.js.map +0 -1
- package/dist/bson.esm.js +0 -5437
- package/dist/bson.esm.js.map +0 -1
- package/lib/binary.js +0 -247
- package/lib/binary.js.map +0 -1
- package/lib/bson.js +0 -265
- package/lib/bson.js.map +0 -1
- package/lib/code.js +0 -46
- package/lib/code.js.map +0 -1
- package/lib/constants.js +0 -82
- package/lib/constants.js.map +0 -1
- package/lib/db_ref.js +0 -97
- package/lib/db_ref.js.map +0 -1
- package/lib/decimal128.js +0 -669
- package/lib/decimal128.js.map +0 -1
- package/lib/double.js +0 -76
- package/lib/double.js.map +0 -1
- package/lib/ensure_buffer.js +0 -25
- package/lib/ensure_buffer.js.map +0 -1
- package/lib/error.js +0 -55
- package/lib/error.js.map +0 -1
- package/lib/extended_json.js +0 -390
- package/lib/extended_json.js.map +0 -1
- package/lib/int_32.js +0 -58
- package/lib/int_32.js.map +0 -1
- package/lib/long.js +0 -900
- package/lib/long.js.map +0 -1
- package/lib/map.js +0 -123
- package/lib/map.js.map +0 -1
- package/lib/max_key.js +0 -33
- package/lib/max_key.js.map +0 -1
- package/lib/min_key.js +0 -33
- package/lib/min_key.js.map +0 -1
- package/lib/objectid.js +0 -299
- package/lib/objectid.js.map +0 -1
- package/lib/parser/calculate_size.js +0 -194
- package/lib/parser/calculate_size.js.map +0 -1
- package/lib/parser/deserializer.js +0 -659
- package/lib/parser/deserializer.js.map +0 -1
- package/lib/parser/serializer.js +0 -867
- package/lib/parser/serializer.js.map +0 -1
- package/lib/parser/utils.js +0 -115
- package/lib/parser/utils.js.map +0 -1
- package/lib/regexp.js +0 -74
- package/lib/regexp.js.map +0 -1
- package/lib/symbol.js +0 -48
- package/lib/symbol.js.map +0 -1
- package/lib/timestamp.js +0 -102
- package/lib/timestamp.js.map +0 -1
- package/lib/utils/global.js +0 -18
- package/lib/utils/global.js.map +0 -1
- package/lib/uuid.js +0 -179
- package/lib/uuid.js.map +0 -1
- package/lib/uuid_utils.js +0 -35
- package/lib/uuid_utils.js.map +0 -1
- package/lib/validate_utf8.js +0 -47
- package/lib/validate_utf8.js.map +0 -1
- package/src/ensure_buffer.ts +0 -27
- package/src/map.ts +0 -119
- package/src/utils/global.ts +0 -22
- package/src/uuid.ts +0 -209
package/lib/binary.js
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Binary = void 0;
|
|
4
|
-
var buffer_1 = require("buffer");
|
|
5
|
-
var ensure_buffer_1 = require("./ensure_buffer");
|
|
6
|
-
var uuid_utils_1 = require("./uuid_utils");
|
|
7
|
-
var uuid_1 = require("./uuid");
|
|
8
|
-
var error_1 = require("./error");
|
|
9
|
-
/**
|
|
10
|
-
* A class representation of the BSON Binary type.
|
|
11
|
-
* @public
|
|
12
|
-
* @category BSONType
|
|
13
|
-
*/
|
|
14
|
-
var Binary = /** @class */ (function () {
|
|
15
|
-
/**
|
|
16
|
-
* Create a new Binary instance.
|
|
17
|
-
*
|
|
18
|
-
* This constructor can accept a string as its first argument. In this case,
|
|
19
|
-
* this string will be encoded using ISO-8859-1, **not** using UTF-8.
|
|
20
|
-
* This is almost certainly not what you want. Use `new Binary(Buffer.from(string))`
|
|
21
|
-
* instead to convert the string to a Buffer using UTF-8 first.
|
|
22
|
-
*
|
|
23
|
-
* @param buffer - a buffer object containing the binary data.
|
|
24
|
-
* @param subType - the option binary type.
|
|
25
|
-
*/
|
|
26
|
-
function Binary(buffer, subType) {
|
|
27
|
-
if (!(this instanceof Binary))
|
|
28
|
-
return new Binary(buffer, subType);
|
|
29
|
-
if (!(buffer == null) &&
|
|
30
|
-
!(typeof buffer === 'string') &&
|
|
31
|
-
!ArrayBuffer.isView(buffer) &&
|
|
32
|
-
!(buffer instanceof ArrayBuffer) &&
|
|
33
|
-
!Array.isArray(buffer)) {
|
|
34
|
-
throw new error_1.BSONTypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
|
|
35
|
-
}
|
|
36
|
-
this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT;
|
|
37
|
-
if (buffer == null) {
|
|
38
|
-
// create an empty binary buffer
|
|
39
|
-
this.buffer = buffer_1.Buffer.alloc(Binary.BUFFER_SIZE);
|
|
40
|
-
this.position = 0;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
if (typeof buffer === 'string') {
|
|
44
|
-
// string
|
|
45
|
-
this.buffer = buffer_1.Buffer.from(buffer, 'binary');
|
|
46
|
-
}
|
|
47
|
-
else if (Array.isArray(buffer)) {
|
|
48
|
-
// number[]
|
|
49
|
-
this.buffer = buffer_1.Buffer.from(buffer);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Buffer | TypedArray | ArrayBuffer
|
|
53
|
-
this.buffer = (0, ensure_buffer_1.ensureBuffer)(buffer);
|
|
54
|
-
}
|
|
55
|
-
this.position = this.buffer.byteLength;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Updates this binary with byte_value.
|
|
60
|
-
*
|
|
61
|
-
* @param byteValue - a single byte we wish to write.
|
|
62
|
-
*/
|
|
63
|
-
Binary.prototype.put = function (byteValue) {
|
|
64
|
-
// If it's a string and a has more than one character throw an error
|
|
65
|
-
if (typeof byteValue === 'string' && byteValue.length !== 1) {
|
|
66
|
-
throw new error_1.BSONTypeError('only accepts single character String');
|
|
67
|
-
}
|
|
68
|
-
else if (typeof byteValue !== 'number' && byteValue.length !== 1)
|
|
69
|
-
throw new error_1.BSONTypeError('only accepts single character Uint8Array or Array');
|
|
70
|
-
// Decode the byte value once
|
|
71
|
-
var decodedByte;
|
|
72
|
-
if (typeof byteValue === 'string') {
|
|
73
|
-
decodedByte = byteValue.charCodeAt(0);
|
|
74
|
-
}
|
|
75
|
-
else if (typeof byteValue === 'number') {
|
|
76
|
-
decodedByte = byteValue;
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
decodedByte = byteValue[0];
|
|
80
|
-
}
|
|
81
|
-
if (decodedByte < 0 || decodedByte > 255) {
|
|
82
|
-
throw new error_1.BSONTypeError('only accepts number in a valid unsigned byte range 0-255');
|
|
83
|
-
}
|
|
84
|
-
if (this.buffer.length > this.position) {
|
|
85
|
-
this.buffer[this.position++] = decodedByte;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
var buffer = buffer_1.Buffer.alloc(Binary.BUFFER_SIZE + this.buffer.length);
|
|
89
|
-
// Combine the two buffers together
|
|
90
|
-
this.buffer.copy(buffer, 0, 0, this.buffer.length);
|
|
91
|
-
this.buffer = buffer;
|
|
92
|
-
this.buffer[this.position++] = decodedByte;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Writes a buffer or string to the binary.
|
|
97
|
-
*
|
|
98
|
-
* @param sequence - a string or buffer to be written to the Binary BSON object.
|
|
99
|
-
* @param offset - specify the binary of where to write the content.
|
|
100
|
-
*/
|
|
101
|
-
Binary.prototype.write = function (sequence, offset) {
|
|
102
|
-
offset = typeof offset === 'number' ? offset : this.position;
|
|
103
|
-
// If the buffer is to small let's extend the buffer
|
|
104
|
-
if (this.buffer.length < offset + sequence.length) {
|
|
105
|
-
var buffer = buffer_1.Buffer.alloc(this.buffer.length + sequence.length);
|
|
106
|
-
this.buffer.copy(buffer, 0, 0, this.buffer.length);
|
|
107
|
-
// Assign the new buffer
|
|
108
|
-
this.buffer = buffer;
|
|
109
|
-
}
|
|
110
|
-
if (ArrayBuffer.isView(sequence)) {
|
|
111
|
-
this.buffer.set((0, ensure_buffer_1.ensureBuffer)(sequence), offset);
|
|
112
|
-
this.position =
|
|
113
|
-
offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
|
|
114
|
-
}
|
|
115
|
-
else if (typeof sequence === 'string') {
|
|
116
|
-
this.buffer.write(sequence, offset, sequence.length, 'binary');
|
|
117
|
-
this.position =
|
|
118
|
-
offset + sequence.length > this.position ? offset + sequence.length : this.position;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Reads **length** bytes starting at **position**.
|
|
123
|
-
*
|
|
124
|
-
* @param position - read from the given position in the Binary.
|
|
125
|
-
* @param length - the number of bytes to read.
|
|
126
|
-
*/
|
|
127
|
-
Binary.prototype.read = function (position, length) {
|
|
128
|
-
length = length && length > 0 ? length : this.position;
|
|
129
|
-
// Let's return the data based on the type we have
|
|
130
|
-
return this.buffer.slice(position, position + length);
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Returns the value of this binary as a string.
|
|
134
|
-
* @param asRaw - Will skip converting to a string
|
|
135
|
-
* @remarks
|
|
136
|
-
* This is handy when calling this function conditionally for some key value pairs and not others
|
|
137
|
-
*/
|
|
138
|
-
Binary.prototype.value = function (asRaw) {
|
|
139
|
-
asRaw = !!asRaw;
|
|
140
|
-
// Optimize to serialize for the situation where the data == size of buffer
|
|
141
|
-
if (asRaw && this.buffer.length === this.position) {
|
|
142
|
-
return this.buffer;
|
|
143
|
-
}
|
|
144
|
-
// If it's a node.js buffer object
|
|
145
|
-
if (asRaw) {
|
|
146
|
-
return this.buffer.slice(0, this.position);
|
|
147
|
-
}
|
|
148
|
-
return this.buffer.toString('binary', 0, this.position);
|
|
149
|
-
};
|
|
150
|
-
/** the length of the binary sequence */
|
|
151
|
-
Binary.prototype.length = function () {
|
|
152
|
-
return this.position;
|
|
153
|
-
};
|
|
154
|
-
Binary.prototype.toJSON = function () {
|
|
155
|
-
return this.buffer.toString('base64');
|
|
156
|
-
};
|
|
157
|
-
Binary.prototype.toString = function (format) {
|
|
158
|
-
return this.buffer.toString(format);
|
|
159
|
-
};
|
|
160
|
-
/** @internal */
|
|
161
|
-
Binary.prototype.toExtendedJSON = function (options) {
|
|
162
|
-
options = options || {};
|
|
163
|
-
var base64String = this.buffer.toString('base64');
|
|
164
|
-
var subType = Number(this.sub_type).toString(16);
|
|
165
|
-
if (options.legacy) {
|
|
166
|
-
return {
|
|
167
|
-
$binary: base64String,
|
|
168
|
-
$type: subType.length === 1 ? '0' + subType : subType
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
$binary: {
|
|
173
|
-
base64: base64String,
|
|
174
|
-
subType: subType.length === 1 ? '0' + subType : subType
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
Binary.prototype.toUUID = function () {
|
|
179
|
-
if (this.sub_type === Binary.SUBTYPE_UUID) {
|
|
180
|
-
return new uuid_1.UUID(this.buffer.slice(0, this.position));
|
|
181
|
-
}
|
|
182
|
-
throw new error_1.BSONError("Binary sub_type \"".concat(this.sub_type, "\" is not supported for converting to UUID. Only \"").concat(Binary.SUBTYPE_UUID, "\" is currently supported."));
|
|
183
|
-
};
|
|
184
|
-
/** @internal */
|
|
185
|
-
Binary.fromExtendedJSON = function (doc, options) {
|
|
186
|
-
options = options || {};
|
|
187
|
-
var data;
|
|
188
|
-
var type;
|
|
189
|
-
if ('$binary' in doc) {
|
|
190
|
-
if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) {
|
|
191
|
-
type = doc.$type ? parseInt(doc.$type, 16) : 0;
|
|
192
|
-
data = buffer_1.Buffer.from(doc.$binary, 'base64');
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
if (typeof doc.$binary !== 'string') {
|
|
196
|
-
type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
|
|
197
|
-
data = buffer_1.Buffer.from(doc.$binary.base64, 'base64');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else if ('$uuid' in doc) {
|
|
202
|
-
type = 4;
|
|
203
|
-
data = (0, uuid_utils_1.uuidHexStringToBuffer)(doc.$uuid);
|
|
204
|
-
}
|
|
205
|
-
if (!data) {
|
|
206
|
-
throw new error_1.BSONTypeError("Unexpected Binary Extended JSON format ".concat(JSON.stringify(doc)));
|
|
207
|
-
}
|
|
208
|
-
return new Binary(data, type);
|
|
209
|
-
};
|
|
210
|
-
/** @internal */
|
|
211
|
-
Binary.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
212
|
-
return this.inspect();
|
|
213
|
-
};
|
|
214
|
-
Binary.prototype.inspect = function () {
|
|
215
|
-
var asBuffer = this.value(true);
|
|
216
|
-
return "new Binary(Buffer.from(\"".concat(asBuffer.toString('hex'), "\", \"hex\"), ").concat(this.sub_type, ")");
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Binary default subtype
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
Binary.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
|
223
|
-
/** Initial buffer default size */
|
|
224
|
-
Binary.BUFFER_SIZE = 256;
|
|
225
|
-
/** Default BSON type */
|
|
226
|
-
Binary.SUBTYPE_DEFAULT = 0;
|
|
227
|
-
/** Function BSON type */
|
|
228
|
-
Binary.SUBTYPE_FUNCTION = 1;
|
|
229
|
-
/** Byte Array BSON type */
|
|
230
|
-
Binary.SUBTYPE_BYTE_ARRAY = 2;
|
|
231
|
-
/** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */
|
|
232
|
-
Binary.SUBTYPE_UUID_OLD = 3;
|
|
233
|
-
/** UUID BSON type */
|
|
234
|
-
Binary.SUBTYPE_UUID = 4;
|
|
235
|
-
/** MD5 BSON type */
|
|
236
|
-
Binary.SUBTYPE_MD5 = 5;
|
|
237
|
-
/** Encrypted BSON type */
|
|
238
|
-
Binary.SUBTYPE_ENCRYPTED = 6;
|
|
239
|
-
/** Column BSON type */
|
|
240
|
-
Binary.SUBTYPE_COLUMN = 7;
|
|
241
|
-
/** User BSON type */
|
|
242
|
-
Binary.SUBTYPE_USER_DEFINED = 128;
|
|
243
|
-
return Binary;
|
|
244
|
-
}());
|
|
245
|
-
exports.Binary = Binary;
|
|
246
|
-
Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' });
|
|
247
|
-
//# sourceMappingURL=binary.js.map
|
package/lib/binary.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../src/binary.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,iDAA+C;AAC/C,2CAAqD;AACrD,+BAA4C;AAE5C,iCAAmD;AAmBnD;;;;GAIG;A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;IAExD,kCAAkC;IAClB,kBAAW,GAAG,GAAG,CAAC;IAClC,wBAAwB;IACR,sBAAe,GAAG,CAAC,CAAC;IACpC,yBAAyB;IACT,uBAAgB,GAAG,CAAC,CAAC;IACrC,2BAA2B;IACX,yBAAkB,GAAG,CAAC,CAAC;IACvC,oEAAoE;IACpD,uBAAgB,GAAG,CAAC,CAAC;IACrC,qBAAqB;IACL,mBAAY,GAAG,CAAC,CAAC;IACjC,oBAAoB;IACJ,kBAAW,GAAG,CAAC,CAAC;IAChC,0BAA0B;IACV,wBAAiB,GAAG,CAAC,CAAC;IACtC,uBAAuB;IACP,qBAAc,GAAG,CAAC,CAAC;IACnC,qBAAqB;IACL,2BAAoB,GAAG,GAAG,CAAC;IA0O7C,aAAC;CAAA,AAtQD,IAsQC;AAtQY,wBAAM;AAwQnB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"}
|
package/lib/bson.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BSONRegExp = exports.MaxKey = exports.MinKey = exports.Int32 = exports.Double = exports.Timestamp = exports.Long = exports.UUID = exports.ObjectId = exports.Binary = exports.DBRef = exports.BSONSymbol = exports.Map = exports.Code = exports.LongWithoutOverridesClass = exports.EJSON = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_STRING = exports.BSON_DATA_REGEXP = exports.BSON_DATA_OID = exports.BSON_DATA_OBJECT = exports.BSON_DATA_NUMBER = exports.BSON_DATA_NULL = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_LONG = exports.BSON_DATA_INT = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_DATE = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_CODE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPTED = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = void 0;
|
|
4
|
-
exports.deserializeStream = exports.calculateObjectSize = exports.deserialize = exports.serializeWithBufferAndIndex = exports.serialize = exports.setInternalBufferSize = exports.BSONTypeError = exports.BSONError = exports.ObjectID = exports.Decimal128 = void 0;
|
|
5
|
-
var buffer_1 = require("buffer");
|
|
6
|
-
var binary_1 = require("./binary");
|
|
7
|
-
Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return binary_1.Binary; } });
|
|
8
|
-
var code_1 = require("./code");
|
|
9
|
-
Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return code_1.Code; } });
|
|
10
|
-
var db_ref_1 = require("./db_ref");
|
|
11
|
-
Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return db_ref_1.DBRef; } });
|
|
12
|
-
var decimal128_1 = require("./decimal128");
|
|
13
|
-
Object.defineProperty(exports, "Decimal128", { enumerable: true, get: function () { return decimal128_1.Decimal128; } });
|
|
14
|
-
var double_1 = require("./double");
|
|
15
|
-
Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return double_1.Double; } });
|
|
16
|
-
var ensure_buffer_1 = require("./ensure_buffer");
|
|
17
|
-
var extended_json_1 = require("./extended_json");
|
|
18
|
-
var int_32_1 = require("./int_32");
|
|
19
|
-
Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32_1.Int32; } });
|
|
20
|
-
var long_1 = require("./long");
|
|
21
|
-
Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return long_1.Long; } });
|
|
22
|
-
var map_1 = require("./map");
|
|
23
|
-
Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map_1.Map; } });
|
|
24
|
-
var max_key_1 = require("./max_key");
|
|
25
|
-
Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return max_key_1.MaxKey; } });
|
|
26
|
-
var min_key_1 = require("./min_key");
|
|
27
|
-
Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return min_key_1.MinKey; } });
|
|
28
|
-
var objectid_1 = require("./objectid");
|
|
29
|
-
Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return objectid_1.ObjectId; } });
|
|
30
|
-
Object.defineProperty(exports, "ObjectID", { enumerable: true, get: function () { return objectid_1.ObjectId; } });
|
|
31
|
-
var error_1 = require("./error");
|
|
32
|
-
var calculate_size_1 = require("./parser/calculate_size");
|
|
33
|
-
// Parts of the parser
|
|
34
|
-
var deserializer_1 = require("./parser/deserializer");
|
|
35
|
-
var serializer_1 = require("./parser/serializer");
|
|
36
|
-
var regexp_1 = require("./regexp");
|
|
37
|
-
Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return regexp_1.BSONRegExp; } });
|
|
38
|
-
var symbol_1 = require("./symbol");
|
|
39
|
-
Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return symbol_1.BSONSymbol; } });
|
|
40
|
-
var timestamp_1 = require("./timestamp");
|
|
41
|
-
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return timestamp_1.Timestamp; } });
|
|
42
|
-
var uuid_1 = require("./uuid");
|
|
43
|
-
Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return uuid_1.UUID; } });
|
|
44
|
-
var binary_2 = require("./binary");
|
|
45
|
-
var code_2 = require("./code");
|
|
46
|
-
var constants_1 = require("./constants");
|
|
47
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_BYTE_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_BYTE_ARRAY; } });
|
|
48
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_DEFAULT", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_DEFAULT; } });
|
|
49
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_FUNCTION", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_FUNCTION; } });
|
|
50
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_MD5", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_MD5; } });
|
|
51
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_USER_DEFINED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_USER_DEFINED; } });
|
|
52
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID; } });
|
|
53
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID_NEW", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID_NEW; } });
|
|
54
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_ENCRYPTED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_ENCRYPTED; } });
|
|
55
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_COLUMN", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_COLUMN; } });
|
|
56
|
-
Object.defineProperty(exports, "BSON_DATA_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_DATA_ARRAY; } });
|
|
57
|
-
Object.defineProperty(exports, "BSON_DATA_BINARY", { enumerable: true, get: function () { return constants_1.BSON_DATA_BINARY; } });
|
|
58
|
-
Object.defineProperty(exports, "BSON_DATA_BOOLEAN", { enumerable: true, get: function () { return constants_1.BSON_DATA_BOOLEAN; } });
|
|
59
|
-
Object.defineProperty(exports, "BSON_DATA_CODE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE; } });
|
|
60
|
-
Object.defineProperty(exports, "BSON_DATA_CODE_W_SCOPE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE_W_SCOPE; } });
|
|
61
|
-
Object.defineProperty(exports, "BSON_DATA_DATE", { enumerable: true, get: function () { return constants_1.BSON_DATA_DATE; } });
|
|
62
|
-
Object.defineProperty(exports, "BSON_DATA_DBPOINTER", { enumerable: true, get: function () { return constants_1.BSON_DATA_DBPOINTER; } });
|
|
63
|
-
Object.defineProperty(exports, "BSON_DATA_DECIMAL128", { enumerable: true, get: function () { return constants_1.BSON_DATA_DECIMAL128; } });
|
|
64
|
-
Object.defineProperty(exports, "BSON_DATA_INT", { enumerable: true, get: function () { return constants_1.BSON_DATA_INT; } });
|
|
65
|
-
Object.defineProperty(exports, "BSON_DATA_LONG", { enumerable: true, get: function () { return constants_1.BSON_DATA_LONG; } });
|
|
66
|
-
Object.defineProperty(exports, "BSON_DATA_MAX_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MAX_KEY; } });
|
|
67
|
-
Object.defineProperty(exports, "BSON_DATA_MIN_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MIN_KEY; } });
|
|
68
|
-
Object.defineProperty(exports, "BSON_DATA_NULL", { enumerable: true, get: function () { return constants_1.BSON_DATA_NULL; } });
|
|
69
|
-
Object.defineProperty(exports, "BSON_DATA_NUMBER", { enumerable: true, get: function () { return constants_1.BSON_DATA_NUMBER; } });
|
|
70
|
-
Object.defineProperty(exports, "BSON_DATA_OBJECT", { enumerable: true, get: function () { return constants_1.BSON_DATA_OBJECT; } });
|
|
71
|
-
Object.defineProperty(exports, "BSON_DATA_OID", { enumerable: true, get: function () { return constants_1.BSON_DATA_OID; } });
|
|
72
|
-
Object.defineProperty(exports, "BSON_DATA_REGEXP", { enumerable: true, get: function () { return constants_1.BSON_DATA_REGEXP; } });
|
|
73
|
-
Object.defineProperty(exports, "BSON_DATA_STRING", { enumerable: true, get: function () { return constants_1.BSON_DATA_STRING; } });
|
|
74
|
-
Object.defineProperty(exports, "BSON_DATA_SYMBOL", { enumerable: true, get: function () { return constants_1.BSON_DATA_SYMBOL; } });
|
|
75
|
-
Object.defineProperty(exports, "BSON_DATA_TIMESTAMP", { enumerable: true, get: function () { return constants_1.BSON_DATA_TIMESTAMP; } });
|
|
76
|
-
Object.defineProperty(exports, "BSON_DATA_UNDEFINED", { enumerable: true, get: function () { return constants_1.BSON_DATA_UNDEFINED; } });
|
|
77
|
-
Object.defineProperty(exports, "BSON_INT32_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT32_MAX; } });
|
|
78
|
-
Object.defineProperty(exports, "BSON_INT32_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT32_MIN; } });
|
|
79
|
-
Object.defineProperty(exports, "BSON_INT64_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT64_MAX; } });
|
|
80
|
-
Object.defineProperty(exports, "BSON_INT64_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT64_MIN; } });
|
|
81
|
-
var db_ref_2 = require("./db_ref");
|
|
82
|
-
var decimal128_2 = require("./decimal128");
|
|
83
|
-
var double_2 = require("./double");
|
|
84
|
-
var extended_json_2 = require("./extended_json");
|
|
85
|
-
Object.defineProperty(exports, "EJSON", { enumerable: true, get: function () { return extended_json_2.EJSON; } });
|
|
86
|
-
var int_32_2 = require("./int_32");
|
|
87
|
-
var long_2 = require("./long");
|
|
88
|
-
var max_key_2 = require("./max_key");
|
|
89
|
-
var min_key_2 = require("./min_key");
|
|
90
|
-
var objectid_2 = require("./objectid");
|
|
91
|
-
var regexp_2 = require("./regexp");
|
|
92
|
-
var symbol_2 = require("./symbol");
|
|
93
|
-
var timestamp_2 = require("./timestamp");
|
|
94
|
-
Object.defineProperty(exports, "LongWithoutOverridesClass", { enumerable: true, get: function () { return timestamp_2.LongWithoutOverridesClass; } });
|
|
95
|
-
var uuid_2 = require("./uuid");
|
|
96
|
-
var error_2 = require("./error");
|
|
97
|
-
Object.defineProperty(exports, "BSONError", { enumerable: true, get: function () { return error_2.BSONError; } });
|
|
98
|
-
Object.defineProperty(exports, "BSONTypeError", { enumerable: true, get: function () { return error_2.BSONTypeError; } });
|
|
99
|
-
/** @internal */
|
|
100
|
-
// Default Max Size
|
|
101
|
-
var MAXSIZE = 1024 * 1024 * 17;
|
|
102
|
-
// Current Internal Temporary Serialization Buffer
|
|
103
|
-
var buffer = buffer_1.Buffer.alloc(MAXSIZE);
|
|
104
|
-
/**
|
|
105
|
-
* Sets the size of the internal serialization buffer.
|
|
106
|
-
*
|
|
107
|
-
* @param size - The desired size for the internal serialization buffer
|
|
108
|
-
* @public
|
|
109
|
-
*/
|
|
110
|
-
function setInternalBufferSize(size) {
|
|
111
|
-
// Resize the internal serialization buffer if needed
|
|
112
|
-
if (buffer.length < size) {
|
|
113
|
-
buffer = buffer_1.Buffer.alloc(size);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.setInternalBufferSize = setInternalBufferSize;
|
|
117
|
-
/**
|
|
118
|
-
* Serialize a Javascript object.
|
|
119
|
-
*
|
|
120
|
-
* @param object - the Javascript object to serialize.
|
|
121
|
-
* @returns Buffer object containing the serialized object.
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
function serialize(object, options) {
|
|
125
|
-
if (options === void 0) { options = {}; }
|
|
126
|
-
// Unpack the options
|
|
127
|
-
var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
128
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
129
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
130
|
-
var minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
|
|
131
|
-
// Resize the internal serialization buffer if needed
|
|
132
|
-
if (buffer.length < minInternalBufferSize) {
|
|
133
|
-
buffer = buffer_1.Buffer.alloc(minInternalBufferSize);
|
|
134
|
-
}
|
|
135
|
-
// Attempt to serialize
|
|
136
|
-
var serializationIndex = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
|
|
137
|
-
// Create the final buffer
|
|
138
|
-
var finishedBuffer = buffer_1.Buffer.alloc(serializationIndex);
|
|
139
|
-
// Copy into the finished buffer
|
|
140
|
-
buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
|
|
141
|
-
// Return the buffer
|
|
142
|
-
return finishedBuffer;
|
|
143
|
-
}
|
|
144
|
-
exports.serialize = serialize;
|
|
145
|
-
/**
|
|
146
|
-
* Serialize a Javascript object using a predefined Buffer and index into the buffer,
|
|
147
|
-
* useful when pre-allocating the space for serialization.
|
|
148
|
-
*
|
|
149
|
-
* @param object - the Javascript object to serialize.
|
|
150
|
-
* @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object.
|
|
151
|
-
* @returns the index pointing to the last written byte in the buffer.
|
|
152
|
-
* @public
|
|
153
|
-
*/
|
|
154
|
-
function serializeWithBufferAndIndex(object, finalBuffer, options) {
|
|
155
|
-
if (options === void 0) { options = {}; }
|
|
156
|
-
// Unpack the options
|
|
157
|
-
var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
158
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
159
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
160
|
-
var startIndex = typeof options.index === 'number' ? options.index : 0;
|
|
161
|
-
// Attempt to serialize
|
|
162
|
-
var serializationIndex = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
|
|
163
|
-
buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
|
|
164
|
-
// Return the index
|
|
165
|
-
return startIndex + serializationIndex - 1;
|
|
166
|
-
}
|
|
167
|
-
exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
|
|
168
|
-
/**
|
|
169
|
-
* Deserialize data as BSON.
|
|
170
|
-
*
|
|
171
|
-
* @param buffer - the buffer containing the serialized set of BSON documents.
|
|
172
|
-
* @returns returns the deserialized Javascript Object.
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
|
-
function deserialize(buffer, options) {
|
|
176
|
-
if (options === void 0) { options = {}; }
|
|
177
|
-
return (0, deserializer_1.deserialize)(buffer instanceof buffer_1.Buffer ? buffer : (0, ensure_buffer_1.ensureBuffer)(buffer), options);
|
|
178
|
-
}
|
|
179
|
-
exports.deserialize = deserialize;
|
|
180
|
-
/**
|
|
181
|
-
* Calculate the bson size for a passed in Javascript object.
|
|
182
|
-
*
|
|
183
|
-
* @param object - the Javascript object to calculate the BSON byte size for
|
|
184
|
-
* @returns size of BSON object in bytes
|
|
185
|
-
* @public
|
|
186
|
-
*/
|
|
187
|
-
function calculateObjectSize(object, options) {
|
|
188
|
-
if (options === void 0) { options = {}; }
|
|
189
|
-
options = options || {};
|
|
190
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
191
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
192
|
-
return (0, calculate_size_1.calculateObjectSize)(object, serializeFunctions, ignoreUndefined);
|
|
193
|
-
}
|
|
194
|
-
exports.calculateObjectSize = calculateObjectSize;
|
|
195
|
-
/**
|
|
196
|
-
* Deserialize stream data as BSON documents.
|
|
197
|
-
*
|
|
198
|
-
* @param data - the buffer containing the serialized set of BSON documents.
|
|
199
|
-
* @param startIndex - the start index in the data Buffer where the deserialization is to start.
|
|
200
|
-
* @param numberOfDocuments - number of documents to deserialize.
|
|
201
|
-
* @param documents - an array where to store the deserialized documents.
|
|
202
|
-
* @param docStartIndex - the index in the documents array from where to start inserting documents.
|
|
203
|
-
* @param options - additional options used for the deserialization.
|
|
204
|
-
* @returns next index in the buffer after deserialization **x** numbers of documents.
|
|
205
|
-
* @public
|
|
206
|
-
*/
|
|
207
|
-
function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
|
|
208
|
-
var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
|
|
209
|
-
var bufferData = (0, ensure_buffer_1.ensureBuffer)(data);
|
|
210
|
-
var index = startIndex;
|
|
211
|
-
// Loop over all documents
|
|
212
|
-
for (var i = 0; i < numberOfDocuments; i++) {
|
|
213
|
-
// Find size of the document
|
|
214
|
-
var size = bufferData[index] |
|
|
215
|
-
(bufferData[index + 1] << 8) |
|
|
216
|
-
(bufferData[index + 2] << 16) |
|
|
217
|
-
(bufferData[index + 3] << 24);
|
|
218
|
-
// Update options with index
|
|
219
|
-
internalOptions.index = index;
|
|
220
|
-
// Parse the document at this point
|
|
221
|
-
documents[docStartIndex + i] = (0, deserializer_1.deserialize)(bufferData, internalOptions);
|
|
222
|
-
// Adjust index by the document size
|
|
223
|
-
index = index + size;
|
|
224
|
-
}
|
|
225
|
-
// Return object containing end index of parsing and list of documents
|
|
226
|
-
return index;
|
|
227
|
-
}
|
|
228
|
-
exports.deserializeStream = deserializeStream;
|
|
229
|
-
/**
|
|
230
|
-
* BSON default export
|
|
231
|
-
* @deprecated Please use named exports
|
|
232
|
-
* @privateRemarks
|
|
233
|
-
* We want to someday deprecate the default export,
|
|
234
|
-
* so none of the new TS types are being exported on the default
|
|
235
|
-
* @public
|
|
236
|
-
*/
|
|
237
|
-
var BSON = {
|
|
238
|
-
Binary: binary_1.Binary,
|
|
239
|
-
Code: code_1.Code,
|
|
240
|
-
DBRef: db_ref_1.DBRef,
|
|
241
|
-
Decimal128: decimal128_1.Decimal128,
|
|
242
|
-
Double: double_1.Double,
|
|
243
|
-
Int32: int_32_1.Int32,
|
|
244
|
-
Long: long_1.Long,
|
|
245
|
-
UUID: uuid_1.UUID,
|
|
246
|
-
Map: map_1.Map,
|
|
247
|
-
MaxKey: max_key_1.MaxKey,
|
|
248
|
-
MinKey: min_key_1.MinKey,
|
|
249
|
-
ObjectId: objectid_1.ObjectId,
|
|
250
|
-
ObjectID: objectid_1.ObjectId,
|
|
251
|
-
BSONRegExp: regexp_1.BSONRegExp,
|
|
252
|
-
BSONSymbol: symbol_1.BSONSymbol,
|
|
253
|
-
Timestamp: timestamp_1.Timestamp,
|
|
254
|
-
EJSON: extended_json_1.EJSON,
|
|
255
|
-
setInternalBufferSize: setInternalBufferSize,
|
|
256
|
-
serialize: serialize,
|
|
257
|
-
serializeWithBufferAndIndex: serializeWithBufferAndIndex,
|
|
258
|
-
deserialize: deserialize,
|
|
259
|
-
calculateObjectSize: calculateObjectSize,
|
|
260
|
-
deserializeStream: deserializeStream,
|
|
261
|
-
BSONError: error_1.BSONError,
|
|
262
|
-
BSONTypeError: error_1.BSONTypeError
|
|
263
|
-
};
|
|
264
|
-
exports.default = BSON;
|
|
265
|
-
//# sourceMappingURL=bson.js.map
|
package/lib/bson.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bson.js","sourceRoot":"","sources":["../src/bson.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,mCAAkC;AAoFhC,uFApFO,eAAM,OAoFP;AAnFR,+BAA8B;AA+E5B,qFA/EO,WAAI,OA+EP;AA9EN,mCAAiC;AAiF/B,sFAjFO,cAAK,OAiFP;AAhFP,2CAA0C;AA2FxC,2FA3FO,uBAAU,OA2FP;AA1FZ,mCAAkC;AAqFhC,uFArFO,eAAM,OAqFP;AApFR,iDAA+C;AAC/C,iDAAwC;AACxC,mCAAiC;AAmF/B,sFAnFO,cAAK,OAmFP;AAlFP,+BAA8B;AA+E5B,qFA/EO,WAAI,OA+EP;AA9EN,6BAA4B;AAwE1B,oFAxEO,SAAG,OAwEP;AA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gBAAA;IACL,IAAI,aAAA;IACJ,IAAI,aAAA;IACJ,GAAG,WAAA;IACH,MAAM,kBAAA;IACN,MAAM,kBAAA;IACN,QAAQ,qBAAA;IACR,QAAQ,EAAE,mBAAQ;IAClB,UAAU,qBAAA;IACV,UAAU,qBAAA;IACV,SAAS,uBAAA;IACT,KAAK,uBAAA;IACL,qBAAqB,uBAAA;IACrB,SAAS,WAAA;IACT,2BAA2B,6BAAA;IAC3B,WAAW,aAAA;IACX,mBAAmB,qBAAA;IACnB,iBAAiB,mBAAA;IACjB,SAAS,mBAAA;IACT,aAAa,uBAAA;CACd,CAAC;AACF,kBAAe,IAAI,CAAC"}
|
package/lib/code.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Code = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A class representation of the BSON Code type.
|
|
6
|
-
* @public
|
|
7
|
-
* @category BSONType
|
|
8
|
-
*/
|
|
9
|
-
var Code = /** @class */ (function () {
|
|
10
|
-
/**
|
|
11
|
-
* @param code - a string or function.
|
|
12
|
-
* @param scope - an optional scope for the function.
|
|
13
|
-
*/
|
|
14
|
-
function Code(code, scope) {
|
|
15
|
-
if (!(this instanceof Code))
|
|
16
|
-
return new Code(code, scope);
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.scope = scope;
|
|
19
|
-
}
|
|
20
|
-
Code.prototype.toJSON = function () {
|
|
21
|
-
return { code: this.code, scope: this.scope };
|
|
22
|
-
};
|
|
23
|
-
/** @internal */
|
|
24
|
-
Code.prototype.toExtendedJSON = function () {
|
|
25
|
-
if (this.scope) {
|
|
26
|
-
return { $code: this.code, $scope: this.scope };
|
|
27
|
-
}
|
|
28
|
-
return { $code: this.code };
|
|
29
|
-
};
|
|
30
|
-
/** @internal */
|
|
31
|
-
Code.fromExtendedJSON = function (doc) {
|
|
32
|
-
return new Code(doc.$code, doc.$scope);
|
|
33
|
-
};
|
|
34
|
-
/** @internal */
|
|
35
|
-
Code.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
36
|
-
return this.inspect();
|
|
37
|
-
};
|
|
38
|
-
Code.prototype.inspect = function () {
|
|
39
|
-
var codeJson = this.toJSON();
|
|
40
|
-
return "new Code(\"".concat(String(codeJson.code), "\"").concat(codeJson.scope ? ", ".concat(JSON.stringify(codeJson.scope)) : '', ")");
|
|
41
|
-
};
|
|
42
|
-
return Code;
|
|
43
|
-
}());
|
|
44
|
-
exports.Code = Code;
|
|
45
|
-
Object.defineProperty(Code.prototype, '_bsontype', { value: 'Code' });
|
|
46
|
-
//# sourceMappingURL=code.js.map
|
package/lib/code.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.js","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":";;;AAQA;;;;GAIG;AACH;IAKE;;;OAGG;IACH,cAAY,IAAuB,EAAE,KAAgB;QACnD,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC;YAAE,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE1D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,qBAAM,GAAN;QACE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAChD,CAAC;IAED,gBAAgB;IAChB,6BAAc,GAAd;QACE,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;SACjD;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,gBAAgB;IACT,qBAAgB,GAAvB,UAAwB,GAAiB;Q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