bson 4.2.3 → 4.5.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/bower.json +1 -1
- package/bson.d.ts +84 -9
- package/dist/bson.browser.esm.js +991 -2292
- package/dist/bson.browser.esm.js.map +1 -1
- package/dist/bson.browser.umd.js +1095 -2397
- package/dist/bson.browser.umd.js.map +1 -1
- package/dist/bson.bundle.js +1097 -2397
- package/dist/bson.bundle.js.map +1 -1
- package/dist/bson.esm.js +945 -2254
- package/dist/bson.esm.js.map +1 -1
- package/lib/binary.js +9 -1
- package/lib/binary.js.map +1 -1
- package/lib/bson.js +6 -2
- package/lib/bson.js.map +1 -1
- package/lib/db_ref.js +4 -1
- package/lib/db_ref.js.map +1 -1
- package/lib/decimal128.js +14 -51
- package/lib/decimal128.js.map +1 -1
- package/lib/ensure_buffer.js +2 -5
- package/lib/ensure_buffer.js.map +1 -1
- package/lib/extended_json.js +48 -9
- package/lib/extended_json.js.map +1 -1
- package/lib/long.js +18 -5
- package/lib/long.js.map +1 -1
- package/lib/map.js +3 -15
- package/lib/map.js.map +1 -1
- package/lib/objectid.js +9 -17
- package/lib/objectid.js.map +1 -1
- package/lib/parser/calculate_size.js +5 -6
- package/lib/parser/calculate_size.js.map +1 -1
- package/lib/parser/deserializer.js +61 -47
- package/lib/parser/deserializer.js.map +1 -1
- package/lib/parser/serializer.js +14 -13
- package/lib/parser/serializer.js.map +1 -1
- package/lib/parser/utils.js +44 -27
- package/lib/parser/utils.js.map +1 -1
- package/lib/regexp.js +1 -3
- package/lib/regexp.js.map +1 -1
- package/lib/timestamp.js +8 -2
- package/lib/timestamp.js.map +1 -1
- package/lib/utils/global.js +18 -0
- package/lib/utils/global.js.map +1 -0
- package/lib/uuid.js +173 -42
- package/lib/uuid.js.map +1 -1
- package/lib/uuid_utils.js +34 -0
- package/lib/uuid_utils.js.map +1 -0
- package/package.json +12 -9
- package/src/binary.ts +14 -2
- package/src/bson.ts +4 -1
- package/src/db_ref.ts +6 -1
- package/src/decimal128.ts +14 -52
- package/src/ensure_buffer.ts +7 -7
- package/src/extended_json.ts +64 -16
- package/src/long.ts +19 -7
- package/src/map.ts +5 -25
- package/src/objectid.ts +12 -19
- package/src/parser/calculate_size.ts +8 -11
- package/src/parser/deserializer.ts +68 -51
- package/src/parser/serializer.ts +13 -12
- package/src/parser/utils.ts +56 -18
- package/src/regexp.ts +2 -4
- package/src/timestamp.ts +15 -7
- package/src/utils/global.ts +22 -0
- package/src/uuid.ts +192 -40
- package/src/uuid_utils.ts +32 -0
- package/HISTORY.md +0 -481
package/bower.json
CHANGED
package/bson.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare class Binary {
|
|
|
62
62
|
/* Excluded from this release type: toJSON */
|
|
63
63
|
/* Excluded from this release type: toString */
|
|
64
64
|
/* Excluded from this release type: toExtendedJSON */
|
|
65
|
+
/* Excluded from this release type: toUUID */
|
|
65
66
|
/* Excluded from this release type: fromExtendedJSON */
|
|
66
67
|
inspect(): string;
|
|
67
68
|
}
|
|
@@ -95,6 +96,7 @@ declare const BSON: {
|
|
|
95
96
|
Double: typeof Double;
|
|
96
97
|
Int32: typeof Int32;
|
|
97
98
|
Long: typeof Long;
|
|
99
|
+
UUID: typeof UUID;
|
|
98
100
|
Map: MapConstructor;
|
|
99
101
|
MaxKey: typeof MaxKey;
|
|
100
102
|
MinKey: typeof MinKey;
|
|
@@ -258,8 +260,11 @@ export declare interface DBRefLike {
|
|
|
258
260
|
export declare class Decimal128 {
|
|
259
261
|
_bsontype: 'Decimal128';
|
|
260
262
|
readonly bytes: Buffer;
|
|
261
|
-
/**
|
|
262
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @param bytes - a buffer containing the raw Decimal128 bytes in little endian order,
|
|
265
|
+
* or a string representation as returned by .toString()
|
|
266
|
+
*/
|
|
267
|
+
constructor(bytes: Buffer | string);
|
|
263
268
|
/**
|
|
264
269
|
* Create a Decimal128 instance from a string representation
|
|
265
270
|
*
|
|
@@ -463,6 +468,7 @@ export declare interface Int32Extended {
|
|
|
463
468
|
$numberInt: string;
|
|
464
469
|
}
|
|
465
470
|
declare const kId: unique symbol;
|
|
471
|
+
declare const kId_2: unique symbol;
|
|
466
472
|
/**
|
|
467
473
|
* A class representing a 64-bit integer
|
|
468
474
|
* @public
|
|
@@ -500,11 +506,17 @@ export declare class Long {
|
|
|
500
506
|
/**
|
|
501
507
|
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
|
|
502
508
|
* See the from* functions below for more convenient ways of constructing Longs.
|
|
509
|
+
*
|
|
510
|
+
* Acceptable signatures are:
|
|
511
|
+
* - Long(low, high, unsigned?)
|
|
512
|
+
* - Long(bigint, unsigned?)
|
|
513
|
+
* - Long(string, unsigned?)
|
|
514
|
+
*
|
|
503
515
|
* @param low - The low (signed) 32 bits of the long
|
|
504
516
|
* @param high - The high (signed) 32 bits of the long
|
|
505
517
|
* @param unsigned - Whether unsigned or not, defaults to signed
|
|
506
518
|
*/
|
|
507
|
-
constructor(low?: number, high?: number, unsigned?: boolean);
|
|
519
|
+
constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean);
|
|
508
520
|
static TWO_PWR_24: Long;
|
|
509
521
|
/** Maximum unsigned value. */
|
|
510
522
|
static MAX_UNSIGNED_VALUE: Long;
|
|
@@ -776,7 +788,7 @@ export declare interface LongExtended {
|
|
|
776
788
|
$numberLong: string;
|
|
777
789
|
}
|
|
778
790
|
/** @public */
|
|
779
|
-
export declare type LongWithoutOverrides = new (low:
|
|
791
|
+
export declare type LongWithoutOverrides = new (low: unknown, high?: number, unsigned?: boolean) => {
|
|
780
792
|
[P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
|
|
781
793
|
};
|
|
782
794
|
/** @public */
|
|
@@ -877,7 +889,7 @@ declare class ObjectId {
|
|
|
877
889
|
*
|
|
878
890
|
* @param id - ObjectId instance to validate.
|
|
879
891
|
*/
|
|
880
|
-
static isValid(id: number | string | ObjectId |
|
|
892
|
+
static isValid(id: number | string | ObjectId | Uint8Array | ObjectIdLike): boolean;
|
|
881
893
|
/* Excluded from this release type: toExtendedJSON */
|
|
882
894
|
/* Excluded from this release type: fromExtendedJSON */
|
|
883
895
|
inspect(): string;
|
|
@@ -938,12 +950,19 @@ export declare class Timestamp extends LongWithoutOverridesClass {
|
|
|
938
950
|
/**
|
|
939
951
|
* @param low - A 64-bit Long representing the Timestamp.
|
|
940
952
|
*/
|
|
941
|
-
constructor(
|
|
953
|
+
constructor(long: Long);
|
|
954
|
+
/**
|
|
955
|
+
* @param value - A pair of two values indicating timestamp and increment.
|
|
956
|
+
*/
|
|
957
|
+
constructor(value: {
|
|
958
|
+
t: number;
|
|
959
|
+
i: number;
|
|
960
|
+
});
|
|
942
961
|
/**
|
|
943
962
|
* @param low - the low (signed) 32 bits of the Timestamp.
|
|
944
963
|
* @param high - the high (signed) 32 bits of the Timestamp.
|
|
964
|
+
* @deprecated Please use `Timestamp({ t: high, i: low })` or `Timestamp(Long(low, high))` instead.
|
|
945
965
|
*/
|
|
946
|
-
constructor(low: Long);
|
|
947
966
|
constructor(low: number, high: number);
|
|
948
967
|
toJSON(): {
|
|
949
968
|
$timestamp: string;
|
|
@@ -979,8 +998,64 @@ export declare interface TimestampExtended {
|
|
|
979
998
|
}
|
|
980
999
|
/** @public */
|
|
981
1000
|
export declare type TimestampOverrides = '_bsontype' | 'toExtendedJSON' | 'fromExtendedJSON' | 'inspect';
|
|
1001
|
+
/**
|
|
1002
|
+
* A class representation of the BSON UUID type.
|
|
1003
|
+
* @public
|
|
1004
|
+
*/
|
|
1005
|
+
export declare class UUID {
|
|
1006
|
+
_bsontype: 'UUID';
|
|
1007
|
+
static cacheHexString: boolean;
|
|
1008
|
+
/* Excluded from this release type: [kId] */
|
|
1009
|
+
/* Excluded from this release type: __id */
|
|
1010
|
+
/**
|
|
1011
|
+
* Create an UUID type
|
|
1012
|
+
*
|
|
1013
|
+
* @param input - Can be a 32 or 36 character hex string (dashes excluded/included) or a 16 byte binary Buffer.
|
|
1014
|
+
*/
|
|
1015
|
+
constructor(input?: string | Buffer | UUID);
|
|
1016
|
+
/*
|
|
1017
|
+
* The UUID bytes
|
|
1018
|
+
* @readonly
|
|
1019
|
+
*/
|
|
1020
|
+
id: Buffer;
|
|
1021
|
+
/**
|
|
1022
|
+
* Generate a 16 byte uuid v4 buffer used in UUIDs
|
|
1023
|
+
*/
|
|
1024
|
+
/**
|
|
1025
|
+
* Returns the UUID id as a 32 or 36 character hex string representation, excluding/including dashes (defaults to 36 character dash separated)
|
|
1026
|
+
* @param includeDashes - should the string exclude dash-separators.
|
|
1027
|
+
* */
|
|
1028
|
+
toHexString(includeDashes?: boolean): string;
|
|
1029
|
+
/* Excluded from this release type: toString */
|
|
1030
|
+
/* Excluded from this release type: toJSON */
|
|
1031
|
+
/**
|
|
1032
|
+
* Compares the equality of this UUID with `otherID`.
|
|
1033
|
+
*
|
|
1034
|
+
* @param otherId - UUID instance to compare against.
|
|
1035
|
+
*/
|
|
1036
|
+
equals(otherId: string | Buffer | UUID): boolean;
|
|
1037
|
+
/**
|
|
1038
|
+
* Creates a Binary instance from the current UUID.
|
|
1039
|
+
*/
|
|
1040
|
+
toBinary(): Binary;
|
|
1041
|
+
/**
|
|
1042
|
+
* Generates a populated buffer containing a v4 uuid
|
|
1043
|
+
*/
|
|
1044
|
+
static generate(): Buffer;
|
|
1045
|
+
/**
|
|
1046
|
+
* Checks if a value is a valid bson UUID
|
|
1047
|
+
* @param input - UUID, string or Buffer to validate.
|
|
1048
|
+
*/
|
|
1049
|
+
static isValid(input: string | Buffer | UUID): boolean;
|
|
1050
|
+
/**
|
|
1051
|
+
* Creates an UUID from a hex string representation of an UUID.
|
|
1052
|
+
* @param hexString - 32 or 36 character hex string (dashes excluded/included).
|
|
1053
|
+
*/
|
|
1054
|
+
static createFromHexString(hexString: string): UUID;
|
|
1055
|
+
inspect(): string;
|
|
1056
|
+
}
|
|
982
1057
|
/** @public */
|
|
983
|
-
export declare
|
|
1058
|
+
export declare type UUIDExtended = {
|
|
984
1059
|
$uuid: string;
|
|
985
|
-
}
|
|
1060
|
+
};
|
|
986
1061
|
export {};
|