bson 6.9.0 → 6.10.1
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 +104 -3
- package/lib/bson.bundle.js +326 -218
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +326 -218
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +326 -218
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.rn.cjs +326 -226
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +1 -2
- package/src/binary.ts +265 -9
- package/src/objectid.ts +18 -11
- package/src/parser/deserializer.ts +17 -45
- package/src/parser/serializer.ts +5 -1
- package/src/parser/utils.ts +30 -51
- package/src/utils/byte_utils.ts +2 -0
- package/src/utils/node_byte_utils.ts +7 -2
- package/src/utils/number_utils.ts +4 -0
- package/src/utils/web_byte_utils.ts +21 -2
|
@@ -100,7 +100,7 @@ export const webByteUtils = {
|
|
|
100
100
|
return new Uint8Array(potentialUint8array);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
throw new BSONError(`Cannot make a Uint8Array from
|
|
103
|
+
throw new BSONError(`Cannot make a Uint8Array from passed potentialBuffer.`);
|
|
104
104
|
},
|
|
105
105
|
|
|
106
106
|
allocate(size: number): Uint8Array {
|
|
@@ -193,5 +193,24 @@ export const webByteUtils = {
|
|
|
193
193
|
return bytes.byteLength;
|
|
194
194
|
},
|
|
195
195
|
|
|
196
|
-
randomBytes: webRandomBytes
|
|
196
|
+
randomBytes: webRandomBytes,
|
|
197
|
+
|
|
198
|
+
swap32(buffer: Uint8Array): Uint8Array {
|
|
199
|
+
if (buffer.length % 4 !== 0) {
|
|
200
|
+
throw new RangeError('Buffer size must be a multiple of 32-bits');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
for (let i = 0; i < buffer.length; i += 4) {
|
|
204
|
+
const byte0 = buffer[i];
|
|
205
|
+
const byte1 = buffer[i + 1];
|
|
206
|
+
const byte2 = buffer[i + 2];
|
|
207
|
+
const byte3 = buffer[i + 3];
|
|
208
|
+
buffer[i] = byte3;
|
|
209
|
+
buffer[i + 1] = byte2;
|
|
210
|
+
buffer[i + 2] = byte1;
|
|
211
|
+
buffer[i + 3] = byte0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return buffer;
|
|
215
|
+
}
|
|
197
216
|
};
|