bson 4.7.0 → 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 +207 -259
- 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 -62
- package/src/binary.ts +63 -52
- package/src/bson.ts +27 -108
- 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 +41 -112
- 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 -7470
- package/dist/bson.browser.esm.js.map +0 -1
- package/dist/bson.browser.umd.js +0 -7537
- package/dist/bson.browser.umd.js.map +0 -1
- package/dist/bson.bundle.js +0 -7536
- package/dist/bson.bundle.js.map +0 -1
- package/dist/bson.esm.js +0 -5436
- package/dist/bson.esm.js.map +0 -1
- package/lib/binary.js +0 -426
- package/lib/binary.js.map +0 -1
- package/lib/bson.js +0 -251
- 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 -665
- 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_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/lib/bson.js
DELETED
|
@@ -1,251 +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
|
-
Object.defineProperty(exports, "UUID", { enumerable: true, get: function () { return binary_1.UUID; } });
|
|
9
|
-
var code_1 = require("./code");
|
|
10
|
-
Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return code_1.Code; } });
|
|
11
|
-
var db_ref_1 = require("./db_ref");
|
|
12
|
-
Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return db_ref_1.DBRef; } });
|
|
13
|
-
var decimal128_1 = require("./decimal128");
|
|
14
|
-
Object.defineProperty(exports, "Decimal128", { enumerable: true, get: function () { return decimal128_1.Decimal128; } });
|
|
15
|
-
var double_1 = require("./double");
|
|
16
|
-
Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return double_1.Double; } });
|
|
17
|
-
var ensure_buffer_1 = require("./ensure_buffer");
|
|
18
|
-
var extended_json_1 = require("./extended_json");
|
|
19
|
-
var int_32_1 = require("./int_32");
|
|
20
|
-
Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return int_32_1.Int32; } });
|
|
21
|
-
var long_1 = require("./long");
|
|
22
|
-
Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return long_1.Long; } });
|
|
23
|
-
var map_1 = require("./map");
|
|
24
|
-
Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map_1.Map; } });
|
|
25
|
-
var max_key_1 = require("./max_key");
|
|
26
|
-
Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return max_key_1.MaxKey; } });
|
|
27
|
-
var min_key_1 = require("./min_key");
|
|
28
|
-
Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return min_key_1.MinKey; } });
|
|
29
|
-
var objectid_1 = require("./objectid");
|
|
30
|
-
Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return objectid_1.ObjectId; } });
|
|
31
|
-
Object.defineProperty(exports, "ObjectID", { enumerable: true, get: function () { return objectid_1.ObjectId; } });
|
|
32
|
-
var error_1 = require("./error");
|
|
33
|
-
var calculate_size_1 = require("./parser/calculate_size");
|
|
34
|
-
// Parts of the parser
|
|
35
|
-
var deserializer_1 = require("./parser/deserializer");
|
|
36
|
-
var serializer_1 = require("./parser/serializer");
|
|
37
|
-
var regexp_1 = require("./regexp");
|
|
38
|
-
Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return regexp_1.BSONRegExp; } });
|
|
39
|
-
var symbol_1 = require("./symbol");
|
|
40
|
-
Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return symbol_1.BSONSymbol; } });
|
|
41
|
-
var timestamp_1 = require("./timestamp");
|
|
42
|
-
Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return timestamp_1.Timestamp; } });
|
|
43
|
-
var constants_1 = require("./constants");
|
|
44
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_BYTE_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_BYTE_ARRAY; } });
|
|
45
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_DEFAULT", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_DEFAULT; } });
|
|
46
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_FUNCTION", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_FUNCTION; } });
|
|
47
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_MD5", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_MD5; } });
|
|
48
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_USER_DEFINED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_USER_DEFINED; } });
|
|
49
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID; } });
|
|
50
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_UUID_NEW", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_UUID_NEW; } });
|
|
51
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_ENCRYPTED", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_ENCRYPTED; } });
|
|
52
|
-
Object.defineProperty(exports, "BSON_BINARY_SUBTYPE_COLUMN", { enumerable: true, get: function () { return constants_1.BSON_BINARY_SUBTYPE_COLUMN; } });
|
|
53
|
-
Object.defineProperty(exports, "BSON_DATA_ARRAY", { enumerable: true, get: function () { return constants_1.BSON_DATA_ARRAY; } });
|
|
54
|
-
Object.defineProperty(exports, "BSON_DATA_BINARY", { enumerable: true, get: function () { return constants_1.BSON_DATA_BINARY; } });
|
|
55
|
-
Object.defineProperty(exports, "BSON_DATA_BOOLEAN", { enumerable: true, get: function () { return constants_1.BSON_DATA_BOOLEAN; } });
|
|
56
|
-
Object.defineProperty(exports, "BSON_DATA_CODE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE; } });
|
|
57
|
-
Object.defineProperty(exports, "BSON_DATA_CODE_W_SCOPE", { enumerable: true, get: function () { return constants_1.BSON_DATA_CODE_W_SCOPE; } });
|
|
58
|
-
Object.defineProperty(exports, "BSON_DATA_DATE", { enumerable: true, get: function () { return constants_1.BSON_DATA_DATE; } });
|
|
59
|
-
Object.defineProperty(exports, "BSON_DATA_DBPOINTER", { enumerable: true, get: function () { return constants_1.BSON_DATA_DBPOINTER; } });
|
|
60
|
-
Object.defineProperty(exports, "BSON_DATA_DECIMAL128", { enumerable: true, get: function () { return constants_1.BSON_DATA_DECIMAL128; } });
|
|
61
|
-
Object.defineProperty(exports, "BSON_DATA_INT", { enumerable: true, get: function () { return constants_1.BSON_DATA_INT; } });
|
|
62
|
-
Object.defineProperty(exports, "BSON_DATA_LONG", { enumerable: true, get: function () { return constants_1.BSON_DATA_LONG; } });
|
|
63
|
-
Object.defineProperty(exports, "BSON_DATA_MAX_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MAX_KEY; } });
|
|
64
|
-
Object.defineProperty(exports, "BSON_DATA_MIN_KEY", { enumerable: true, get: function () { return constants_1.BSON_DATA_MIN_KEY; } });
|
|
65
|
-
Object.defineProperty(exports, "BSON_DATA_NULL", { enumerable: true, get: function () { return constants_1.BSON_DATA_NULL; } });
|
|
66
|
-
Object.defineProperty(exports, "BSON_DATA_NUMBER", { enumerable: true, get: function () { return constants_1.BSON_DATA_NUMBER; } });
|
|
67
|
-
Object.defineProperty(exports, "BSON_DATA_OBJECT", { enumerable: true, get: function () { return constants_1.BSON_DATA_OBJECT; } });
|
|
68
|
-
Object.defineProperty(exports, "BSON_DATA_OID", { enumerable: true, get: function () { return constants_1.BSON_DATA_OID; } });
|
|
69
|
-
Object.defineProperty(exports, "BSON_DATA_REGEXP", { enumerable: true, get: function () { return constants_1.BSON_DATA_REGEXP; } });
|
|
70
|
-
Object.defineProperty(exports, "BSON_DATA_STRING", { enumerable: true, get: function () { return constants_1.BSON_DATA_STRING; } });
|
|
71
|
-
Object.defineProperty(exports, "BSON_DATA_SYMBOL", { enumerable: true, get: function () { return constants_1.BSON_DATA_SYMBOL; } });
|
|
72
|
-
Object.defineProperty(exports, "BSON_DATA_TIMESTAMP", { enumerable: true, get: function () { return constants_1.BSON_DATA_TIMESTAMP; } });
|
|
73
|
-
Object.defineProperty(exports, "BSON_DATA_UNDEFINED", { enumerable: true, get: function () { return constants_1.BSON_DATA_UNDEFINED; } });
|
|
74
|
-
Object.defineProperty(exports, "BSON_INT32_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT32_MAX; } });
|
|
75
|
-
Object.defineProperty(exports, "BSON_INT32_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT32_MIN; } });
|
|
76
|
-
Object.defineProperty(exports, "BSON_INT64_MAX", { enumerable: true, get: function () { return constants_1.BSON_INT64_MAX; } });
|
|
77
|
-
Object.defineProperty(exports, "BSON_INT64_MIN", { enumerable: true, get: function () { return constants_1.BSON_INT64_MIN; } });
|
|
78
|
-
var extended_json_2 = require("./extended_json");
|
|
79
|
-
Object.defineProperty(exports, "EJSON", { enumerable: true, get: function () { return extended_json_2.EJSON; } });
|
|
80
|
-
var timestamp_2 = require("./timestamp");
|
|
81
|
-
Object.defineProperty(exports, "LongWithoutOverridesClass", { enumerable: true, get: function () { return timestamp_2.LongWithoutOverridesClass; } });
|
|
82
|
-
var error_2 = require("./error");
|
|
83
|
-
Object.defineProperty(exports, "BSONError", { enumerable: true, get: function () { return error_2.BSONError; } });
|
|
84
|
-
Object.defineProperty(exports, "BSONTypeError", { enumerable: true, get: function () { return error_2.BSONTypeError; } });
|
|
85
|
-
/** @internal */
|
|
86
|
-
// Default Max Size
|
|
87
|
-
var MAXSIZE = 1024 * 1024 * 17;
|
|
88
|
-
// Current Internal Temporary Serialization Buffer
|
|
89
|
-
var buffer = buffer_1.Buffer.alloc(MAXSIZE);
|
|
90
|
-
/**
|
|
91
|
-
* Sets the size of the internal serialization buffer.
|
|
92
|
-
*
|
|
93
|
-
* @param size - The desired size for the internal serialization buffer
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
function setInternalBufferSize(size) {
|
|
97
|
-
// Resize the internal serialization buffer if needed
|
|
98
|
-
if (buffer.length < size) {
|
|
99
|
-
buffer = buffer_1.Buffer.alloc(size);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.setInternalBufferSize = setInternalBufferSize;
|
|
103
|
-
/**
|
|
104
|
-
* Serialize a Javascript object.
|
|
105
|
-
*
|
|
106
|
-
* @param object - the Javascript object to serialize.
|
|
107
|
-
* @returns Buffer object containing the serialized object.
|
|
108
|
-
* @public
|
|
109
|
-
*/
|
|
110
|
-
function serialize(object, options) {
|
|
111
|
-
if (options === void 0) { options = {}; }
|
|
112
|
-
// Unpack the options
|
|
113
|
-
var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
114
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
115
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
116
|
-
var minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
|
|
117
|
-
// Resize the internal serialization buffer if needed
|
|
118
|
-
if (buffer.length < minInternalBufferSize) {
|
|
119
|
-
buffer = buffer_1.Buffer.alloc(minInternalBufferSize);
|
|
120
|
-
}
|
|
121
|
-
// Attempt to serialize
|
|
122
|
-
var serializationIndex = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, []);
|
|
123
|
-
// Create the final buffer
|
|
124
|
-
var finishedBuffer = buffer_1.Buffer.alloc(serializationIndex);
|
|
125
|
-
// Copy into the finished buffer
|
|
126
|
-
buffer.copy(finishedBuffer, 0, 0, finishedBuffer.length);
|
|
127
|
-
// Return the buffer
|
|
128
|
-
return finishedBuffer;
|
|
129
|
-
}
|
|
130
|
-
exports.serialize = serialize;
|
|
131
|
-
/**
|
|
132
|
-
* Serialize a Javascript object using a predefined Buffer and index into the buffer,
|
|
133
|
-
* useful when pre-allocating the space for serialization.
|
|
134
|
-
*
|
|
135
|
-
* @param object - the Javascript object to serialize.
|
|
136
|
-
* @param finalBuffer - the Buffer you pre-allocated to store the serialized BSON object.
|
|
137
|
-
* @returns the index pointing to the last written byte in the buffer.
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
|
-
function serializeWithBufferAndIndex(object, finalBuffer, options) {
|
|
141
|
-
if (options === void 0) { options = {}; }
|
|
142
|
-
// Unpack the options
|
|
143
|
-
var checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
144
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
145
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
146
|
-
var startIndex = typeof options.index === 'number' ? options.index : 0;
|
|
147
|
-
// Attempt to serialize
|
|
148
|
-
var serializationIndex = (0, serializer_1.serializeInto)(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined);
|
|
149
|
-
buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
|
|
150
|
-
// Return the index
|
|
151
|
-
return startIndex + serializationIndex - 1;
|
|
152
|
-
}
|
|
153
|
-
exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
|
|
154
|
-
/**
|
|
155
|
-
* Deserialize data as BSON.
|
|
156
|
-
*
|
|
157
|
-
* @param buffer - the buffer containing the serialized set of BSON documents.
|
|
158
|
-
* @returns returns the deserialized Javascript Object.
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
function deserialize(buffer, options) {
|
|
162
|
-
if (options === void 0) { options = {}; }
|
|
163
|
-
return (0, deserializer_1.deserialize)(buffer instanceof buffer_1.Buffer ? buffer : (0, ensure_buffer_1.ensureBuffer)(buffer), options);
|
|
164
|
-
}
|
|
165
|
-
exports.deserialize = deserialize;
|
|
166
|
-
/**
|
|
167
|
-
* Calculate the bson size for a passed in Javascript object.
|
|
168
|
-
*
|
|
169
|
-
* @param object - the Javascript object to calculate the BSON byte size for
|
|
170
|
-
* @returns size of BSON object in bytes
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
function calculateObjectSize(object, options) {
|
|
174
|
-
if (options === void 0) { options = {}; }
|
|
175
|
-
options = options || {};
|
|
176
|
-
var serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
177
|
-
var ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
178
|
-
return (0, calculate_size_1.calculateObjectSize)(object, serializeFunctions, ignoreUndefined);
|
|
179
|
-
}
|
|
180
|
-
exports.calculateObjectSize = calculateObjectSize;
|
|
181
|
-
/**
|
|
182
|
-
* Deserialize stream data as BSON documents.
|
|
183
|
-
*
|
|
184
|
-
* @param data - the buffer containing the serialized set of BSON documents.
|
|
185
|
-
* @param startIndex - the start index in the data Buffer where the deserialization is to start.
|
|
186
|
-
* @param numberOfDocuments - number of documents to deserialize.
|
|
187
|
-
* @param documents - an array where to store the deserialized documents.
|
|
188
|
-
* @param docStartIndex - the index in the documents array from where to start inserting documents.
|
|
189
|
-
* @param options - additional options used for the deserialization.
|
|
190
|
-
* @returns next index in the buffer after deserialization **x** numbers of documents.
|
|
191
|
-
* @public
|
|
192
|
-
*/
|
|
193
|
-
function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
|
|
194
|
-
var internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
|
|
195
|
-
var bufferData = (0, ensure_buffer_1.ensureBuffer)(data);
|
|
196
|
-
var index = startIndex;
|
|
197
|
-
// Loop over all documents
|
|
198
|
-
for (var i = 0; i < numberOfDocuments; i++) {
|
|
199
|
-
// Find size of the document
|
|
200
|
-
var size = bufferData[index] |
|
|
201
|
-
(bufferData[index + 1] << 8) |
|
|
202
|
-
(bufferData[index + 2] << 16) |
|
|
203
|
-
(bufferData[index + 3] << 24);
|
|
204
|
-
// Update options with index
|
|
205
|
-
internalOptions.index = index;
|
|
206
|
-
// Parse the document at this point
|
|
207
|
-
documents[docStartIndex + i] = (0, deserializer_1.deserialize)(bufferData, internalOptions);
|
|
208
|
-
// Adjust index by the document size
|
|
209
|
-
index = index + size;
|
|
210
|
-
}
|
|
211
|
-
// Return object containing end index of parsing and list of documents
|
|
212
|
-
return index;
|
|
213
|
-
}
|
|
214
|
-
exports.deserializeStream = deserializeStream;
|
|
215
|
-
/**
|
|
216
|
-
* BSON default export
|
|
217
|
-
* @deprecated Please use named exports
|
|
218
|
-
* @privateRemarks
|
|
219
|
-
* We want to someday deprecate the default export,
|
|
220
|
-
* so none of the new TS types are being exported on the default
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
var BSON = {
|
|
224
|
-
Binary: binary_1.Binary,
|
|
225
|
-
Code: code_1.Code,
|
|
226
|
-
DBRef: db_ref_1.DBRef,
|
|
227
|
-
Decimal128: decimal128_1.Decimal128,
|
|
228
|
-
Double: double_1.Double,
|
|
229
|
-
Int32: int_32_1.Int32,
|
|
230
|
-
Long: long_1.Long,
|
|
231
|
-
UUID: binary_1.UUID,
|
|
232
|
-
Map: map_1.Map,
|
|
233
|
-
MaxKey: max_key_1.MaxKey,
|
|
234
|
-
MinKey: min_key_1.MinKey,
|
|
235
|
-
ObjectId: objectid_1.ObjectId,
|
|
236
|
-
ObjectID: objectid_1.ObjectId,
|
|
237
|
-
BSONRegExp: regexp_1.BSONRegExp,
|
|
238
|
-
BSONSymbol: symbol_1.BSONSymbol,
|
|
239
|
-
Timestamp: timestamp_1.Timestamp,
|
|
240
|
-
EJSON: extended_json_1.EJSON,
|
|
241
|
-
setInternalBufferSize: setInternalBufferSize,
|
|
242
|
-
serialize: serialize,
|
|
243
|
-
serializeWithBufferAndIndex: serializeWithBufferAndIndex,
|
|
244
|
-
deserialize: deserialize,
|
|
245
|
-
calculateObjectSize: calculateObjectSize,
|
|
246
|
-
deserializeStream: deserializeStream,
|
|
247
|
-
BSONError: error_1.BSONError,
|
|
248
|
-
BSONTypeError: error_1.BSONTypeError
|
|
249
|
-
};
|
|
250
|
-
exports.default = BSON;
|
|
251
|
-
//# 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,mCAAwC;AA+EtC,uFA/EO,eAAM,OA+EP;AAEN,qFAjFe,aAAI,OAiFf;AAhFN,+BAA8B;AA0E5B,qFA1EO,WAAI,OA0EP;AAzEN,mCAAiC;AA4E/B,sFA5EO,cAAK,OA4EP;AA3EP,2CAA0C;AAsFxC,2FAtFO,uBAAU,OAsFP;AArFZ,mCAAkC;AAgFhC,uFAhFO,eAAM,OAgFP;AA/ER,iDAA+C;AAC/C,iDAAwC;AACxC,mCAAiC;AA8E/B,sFA9EO,cAAK,OA8EP;AA7EP,+BAA8B;AA0E5B,qFA1EO,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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;QACvC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,gBAAgB;IAChB,eAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,GAA1C;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,sBAAO,GAAP;QACE,IAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/B,OAAO,qBAAa,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,eACvC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,YAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAE,CAAC,CAAC,CAAC,EAAE,MAC1D,CAAC;IACN,CAAC;IACH,WAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,oBAAI;AA+CjB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC"}
|
package/lib/constants.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPTED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = void 0;
|
|
4
|
-
/** @internal */
|
|
5
|
-
exports.BSON_INT32_MAX = 0x7fffffff;
|
|
6
|
-
/** @internal */
|
|
7
|
-
exports.BSON_INT32_MIN = -0x80000000;
|
|
8
|
-
/** @internal */
|
|
9
|
-
exports.BSON_INT64_MAX = Math.pow(2, 63) - 1;
|
|
10
|
-
/** @internal */
|
|
11
|
-
exports.BSON_INT64_MIN = -Math.pow(2, 63);
|
|
12
|
-
/**
|
|
13
|
-
* Any integer up to 2^53 can be precisely represented by a double.
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
exports.JS_INT_MAX = Math.pow(2, 53);
|
|
17
|
-
/**
|
|
18
|
-
* Any integer down to -2^53 can be precisely represented by a double.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
exports.JS_INT_MIN = -Math.pow(2, 53);
|
|
22
|
-
/** Number BSON Type @internal */
|
|
23
|
-
exports.BSON_DATA_NUMBER = 1;
|
|
24
|
-
/** String BSON Type @internal */
|
|
25
|
-
exports.BSON_DATA_STRING = 2;
|
|
26
|
-
/** Object BSON Type @internal */
|
|
27
|
-
exports.BSON_DATA_OBJECT = 3;
|
|
28
|
-
/** Array BSON Type @internal */
|
|
29
|
-
exports.BSON_DATA_ARRAY = 4;
|
|
30
|
-
/** Binary BSON Type @internal */
|
|
31
|
-
exports.BSON_DATA_BINARY = 5;
|
|
32
|
-
/** Binary BSON Type @internal */
|
|
33
|
-
exports.BSON_DATA_UNDEFINED = 6;
|
|
34
|
-
/** ObjectId BSON Type @internal */
|
|
35
|
-
exports.BSON_DATA_OID = 7;
|
|
36
|
-
/** Boolean BSON Type @internal */
|
|
37
|
-
exports.BSON_DATA_BOOLEAN = 8;
|
|
38
|
-
/** Date BSON Type @internal */
|
|
39
|
-
exports.BSON_DATA_DATE = 9;
|
|
40
|
-
/** null BSON Type @internal */
|
|
41
|
-
exports.BSON_DATA_NULL = 10;
|
|
42
|
-
/** RegExp BSON Type @internal */
|
|
43
|
-
exports.BSON_DATA_REGEXP = 11;
|
|
44
|
-
/** Code BSON Type @internal */
|
|
45
|
-
exports.BSON_DATA_DBPOINTER = 12;
|
|
46
|
-
/** Code BSON Type @internal */
|
|
47
|
-
exports.BSON_DATA_CODE = 13;
|
|
48
|
-
/** Symbol BSON Type @internal */
|
|
49
|
-
exports.BSON_DATA_SYMBOL = 14;
|
|
50
|
-
/** Code with Scope BSON Type @internal */
|
|
51
|
-
exports.BSON_DATA_CODE_W_SCOPE = 15;
|
|
52
|
-
/** 32 bit Integer BSON Type @internal */
|
|
53
|
-
exports.BSON_DATA_INT = 16;
|
|
54
|
-
/** Timestamp BSON Type @internal */
|
|
55
|
-
exports.BSON_DATA_TIMESTAMP = 17;
|
|
56
|
-
/** Long BSON Type @internal */
|
|
57
|
-
exports.BSON_DATA_LONG = 18;
|
|
58
|
-
/** Decimal128 BSON Type @internal */
|
|
59
|
-
exports.BSON_DATA_DECIMAL128 = 19;
|
|
60
|
-
/** MinKey BSON Type @internal */
|
|
61
|
-
exports.BSON_DATA_MIN_KEY = 0xff;
|
|
62
|
-
/** MaxKey BSON Type @internal */
|
|
63
|
-
exports.BSON_DATA_MAX_KEY = 0x7f;
|
|
64
|
-
/** Binary Default Type @internal */
|
|
65
|
-
exports.BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
|
66
|
-
/** Binary Function Type @internal */
|
|
67
|
-
exports.BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
|
68
|
-
/** Binary Byte Array Type @internal */
|
|
69
|
-
exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
|
70
|
-
/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
|
|
71
|
-
exports.BSON_BINARY_SUBTYPE_UUID = 3;
|
|
72
|
-
/** Binary UUID Type @internal */
|
|
73
|
-
exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4;
|
|
74
|
-
/** Binary MD5 Type @internal */
|
|
75
|
-
exports.BSON_BINARY_SUBTYPE_MD5 = 5;
|
|
76
|
-
/** Encrypted BSON type @internal */
|
|
77
|
-
exports.BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
|
|
78
|
-
/** Column BSON type @internal */
|
|
79
|
-
exports.BSON_BINARY_SUBTYPE_COLUMN = 7;
|
|
80
|
-
/** Binary User Defined Type @internal */
|
|
81
|
-
exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
|
82
|
-
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,gBAAgB;AACH,QAAA,cAAc,GAAG,UAAU,CAAC;AACzC,gBAAgB;AACH,QAAA,cAAc,GAAG,CAAC,UAAU,CAAC;AAC1C,gBAAgB;AACH,QAAA,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AAClD,gBAAgB;AACH,QAAA,cAAc,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE/C;;;GAGG;AACU,QAAA,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE1C;;;GAGG;AACU,QAAA,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE3C,iCAAiC;AACpB,QAAA,gBAAgB,GAAG,CAAC,CAAC;AAElC,iCAAiC;AACpB,QAAA,gBAAgB,GAAG,CA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AAC;AAE1C,iCAAiC;AACpB,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAE9C,gCAAgC;AACnB,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAEzC,oCAAoC;AACvB,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAE/C,iCAAiC;AACpB,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAE5C,yCAAyC;AAC5B,QAAA,gCAAgC,GAAG,GAAG,CAAC"}
|
package/lib/db_ref.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DBRef = exports.isDBRefLike = void 0;
|
|
4
|
-
var utils_1 = require("./parser/utils");
|
|
5
|
-
/** @internal */
|
|
6
|
-
function isDBRefLike(value) {
|
|
7
|
-
return ((0, utils_1.isObjectLike)(value) &&
|
|
8
|
-
value.$id != null &&
|
|
9
|
-
typeof value.$ref === 'string' &&
|
|
10
|
-
(value.$db == null || typeof value.$db === 'string'));
|
|
11
|
-
}
|
|
12
|
-
exports.isDBRefLike = isDBRefLike;
|
|
13
|
-
/**
|
|
14
|
-
* A class representation of the BSON DBRef type.
|
|
15
|
-
* @public
|
|
16
|
-
* @category BSONType
|
|
17
|
-
*/
|
|
18
|
-
var DBRef = /** @class */ (function () {
|
|
19
|
-
/**
|
|
20
|
-
* @param collection - the collection name.
|
|
21
|
-
* @param oid - the reference ObjectId.
|
|
22
|
-
* @param db - optional db name, if omitted the reference is local to the current db.
|
|
23
|
-
*/
|
|
24
|
-
function DBRef(collection, oid, db, fields) {
|
|
25
|
-
if (!(this instanceof DBRef))
|
|
26
|
-
return new DBRef(collection, oid, db, fields);
|
|
27
|
-
// check if namespace has been provided
|
|
28
|
-
var parts = collection.split('.');
|
|
29
|
-
if (parts.length === 2) {
|
|
30
|
-
db = parts.shift();
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
-
collection = parts.shift();
|
|
33
|
-
}
|
|
34
|
-
this.collection = collection;
|
|
35
|
-
this.oid = oid;
|
|
36
|
-
this.db = db;
|
|
37
|
-
this.fields = fields || {};
|
|
38
|
-
}
|
|
39
|
-
Object.defineProperty(DBRef.prototype, "namespace", {
|
|
40
|
-
// Property provided for compatibility with the 1.x parser
|
|
41
|
-
// the 1.x parser used a "namespace" property, while 4.x uses "collection"
|
|
42
|
-
/** @internal */
|
|
43
|
-
get: function () {
|
|
44
|
-
return this.collection;
|
|
45
|
-
},
|
|
46
|
-
set: function (value) {
|
|
47
|
-
this.collection = value;
|
|
48
|
-
},
|
|
49
|
-
enumerable: false,
|
|
50
|
-
configurable: true
|
|
51
|
-
});
|
|
52
|
-
DBRef.prototype.toJSON = function () {
|
|
53
|
-
var o = Object.assign({
|
|
54
|
-
$ref: this.collection,
|
|
55
|
-
$id: this.oid
|
|
56
|
-
}, this.fields);
|
|
57
|
-
if (this.db != null)
|
|
58
|
-
o.$db = this.db;
|
|
59
|
-
return o;
|
|
60
|
-
};
|
|
61
|
-
/** @internal */
|
|
62
|
-
DBRef.prototype.toExtendedJSON = function (options) {
|
|
63
|
-
options = options || {};
|
|
64
|
-
var o = {
|
|
65
|
-
$ref: this.collection,
|
|
66
|
-
$id: this.oid
|
|
67
|
-
};
|
|
68
|
-
if (options.legacy) {
|
|
69
|
-
return o;
|
|
70
|
-
}
|
|
71
|
-
if (this.db)
|
|
72
|
-
o.$db = this.db;
|
|
73
|
-
o = Object.assign(o, this.fields);
|
|
74
|
-
return o;
|
|
75
|
-
};
|
|
76
|
-
/** @internal */
|
|
77
|
-
DBRef.fromExtendedJSON = function (doc) {
|
|
78
|
-
var copy = Object.assign({}, doc);
|
|
79
|
-
delete copy.$ref;
|
|
80
|
-
delete copy.$id;
|
|
81
|
-
delete copy.$db;
|
|
82
|
-
return new DBRef(doc.$ref, doc.$id, doc.$db, copy);
|
|
83
|
-
};
|
|
84
|
-
/** @internal */
|
|
85
|
-
DBRef.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
|
|
86
|
-
return this.inspect();
|
|
87
|
-
};
|
|
88
|
-
DBRef.prototype.inspect = function () {
|
|
89
|
-
// NOTE: if OID is an ObjectId class it will just print the oid string.
|
|
90
|
-
var oid = this.oid === undefined || this.oid.toString === undefined ? this.oid : this.oid.toString();
|
|
91
|
-
return "new DBRef(\"".concat(this.namespace, "\", new ObjectId(\"").concat(String(oid), "\")").concat(this.db ? ", \"".concat(this.db, "\"") : '', ")");
|
|
92
|
-
};
|
|
93
|
-
return DBRef;
|
|
94
|
-
}());
|
|
95
|
-
exports.DBRef = DBRef;
|
|
96
|
-
Object.defineProperty(DBRef.prototype, '_bsontype', { value: 'DBRef' });
|
|
97
|
-
//# sourceMappingURL=db_ref.js.map
|
package/lib/db_ref.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db_ref.js","sourceRoot":"","sources":["../src/db_ref.ts"],"names":[],"mappings":";;;AAGA,wCAA8C;AAS9C,gBAAgB;AAChB,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,IAAA,oBAAY,EAAC,KAAK,CAAC;QACnB,KAAK,CAAC,GAAG,IAAI,IAAI;QACjB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,CACrD,CAAC;AACJ,CAAC;AAPD,kCAOC;AAED;;;;GAIG;AACH;IAQE;;;;OAIG;IACH,eAAY,UAAkB,EAAE,GAAa,EAAE,EAAW,EAAE,MAAiB;QAC3E,IAAI,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC;YAAE,OAAO,IAAI,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAE5E,uCAAuC;QACvC,IAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,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