bson 7.1.1 → 7.2.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/lib/bson.rn.cjs CHANGED
@@ -269,6 +269,11 @@ const nodeJsByteUtils = {
269
269
  concat(list) {
270
270
  return Buffer.concat(list);
271
271
  },
272
+ copy(source, target, targetStart, sourceStart, sourceEnd) {
273
+ return nodeJsByteUtils
274
+ .toLocalBufferType(source)
275
+ .copy(target, targetStart ?? 0, sourceStart ?? 0, sourceEnd ?? source.length);
276
+ },
272
277
  equals(a, b) {
273
278
  return nodeJsByteUtils.toLocalBufferType(a).equals(b);
274
279
  },
@@ -413,6 +418,27 @@ const webByteUtils = {
413
418
  }
414
419
  return result;
415
420
  },
421
+ copy(source, target, targetStart, sourceStart, sourceEnd) {
422
+ if (sourceEnd !== undefined && sourceEnd < 0) {
423
+ throw new RangeError(`The value of "sourceEnd" is out of range. It must be >= 0. Received ${sourceEnd}`);
424
+ }
425
+ sourceEnd = sourceEnd ?? source.length;
426
+ if (sourceStart !== undefined && (sourceStart < 0 || sourceStart > sourceEnd)) {
427
+ throw new RangeError(`The value of "sourceStart" is out of range. It must be >= 0 and <= ${sourceEnd}. Received ${sourceStart}`);
428
+ }
429
+ sourceStart = sourceStart ?? 0;
430
+ if (targetStart !== undefined && targetStart < 0) {
431
+ throw new RangeError(`The value of "targetStart" is out of range. It must be >= 0. Received ${targetStart}`);
432
+ }
433
+ targetStart = targetStart ?? 0;
434
+ const srcSlice = source.subarray(sourceStart, sourceEnd);
435
+ const maxLen = Math.min(srcSlice.length, target.length - targetStart);
436
+ if (maxLen <= 0) {
437
+ return 0;
438
+ }
439
+ target.set(srcSlice.subarray(0, maxLen), targetStart);
440
+ return maxLen;
441
+ },
416
442
  equals(uint8Array, otherUint8Array) {
417
443
  if (uint8Array.byteLength !== otherUint8Array.byteLength) {
418
444
  return false;
@@ -4320,7 +4346,7 @@ function serializeValue(value, options) {
4320
4346
  if (Array.isArray(value))
4321
4347
  return serializeArray(value, options);
4322
4348
  if (value === undefined)
4323
- return null;
4349
+ return options.ignoreUndefined ? undefined : null;
4324
4350
  if (value instanceof Date || isDate(value)) {
4325
4351
  const dateNum = value.getTime(), inRange = dateNum > -1 && dateNum < 253402318800000;
4326
4352
  if (options.legacy) {