bson 4.5.0 → 4.5.4

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.
Files changed (68) hide show
  1. package/bower.json +1 -1
  2. package/bson.d.ts +50 -13
  3. package/dist/bson.browser.esm.js +233 -180
  4. package/dist/bson.browser.esm.js.map +1 -1
  5. package/dist/bson.browser.umd.js +236 -179
  6. package/dist/bson.browser.umd.js.map +1 -1
  7. package/dist/bson.bundle.js +236 -179
  8. package/dist/bson.bundle.js.map +1 -1
  9. package/dist/bson.esm.js +233 -180
  10. package/dist/bson.esm.js.map +1 -1
  11. package/lib/binary.js +11 -9
  12. package/lib/binary.js.map +1 -1
  13. package/lib/bson.js +11 -3
  14. package/lib/bson.js.map +1 -1
  15. package/lib/code.js +0 -1
  16. package/lib/code.js.map +1 -1
  17. package/lib/constants.js +5 -1
  18. package/lib/constants.js.map +1 -1
  19. package/lib/db_ref.js +0 -1
  20. package/lib/db_ref.js.map +1 -1
  21. package/lib/decimal128.js +6 -5
  22. package/lib/decimal128.js.map +1 -1
  23. package/lib/double.js +3 -1
  24. package/lib/double.js.map +1 -1
  25. package/lib/ensure_buffer.js +2 -1
  26. package/lib/ensure_buffer.js.map +1 -1
  27. package/lib/error.js +51 -0
  28. package/lib/error.js.map +1 -0
  29. package/lib/extended_json.js +11 -5
  30. package/lib/extended_json.js.map +1 -1
  31. package/lib/int_32.js +4 -2
  32. package/lib/int_32.js.map +1 -1
  33. package/lib/objectid.js +39 -35
  34. package/lib/objectid.js.map +1 -1
  35. package/lib/parser/deserializer.js +60 -51
  36. package/lib/parser/deserializer.js.map +1 -1
  37. package/lib/parser/serializer.js +13 -12
  38. package/lib/parser/serializer.js.map +1 -1
  39. package/lib/parser/utils.js +0 -6
  40. package/lib/parser/utils.js.map +1 -1
  41. package/lib/regexp.js +9 -2
  42. package/lib/regexp.js.map +1 -1
  43. package/lib/symbol.js +0 -2
  44. package/lib/symbol.js.map +1 -1
  45. package/lib/uuid.js +4 -4
  46. package/lib/uuid.js.map +1 -1
  47. package/lib/uuid_utils.js +2 -1
  48. package/lib/uuid_utils.js.map +1 -1
  49. package/package.json +15 -2
  50. package/src/binary.ts +12 -10
  51. package/src/bson.ts +7 -1
  52. package/src/code.ts +0 -1
  53. package/src/constants.ts +6 -0
  54. package/src/db_ref.ts +0 -1
  55. package/src/decimal128.ts +6 -5
  56. package/src/double.ts +4 -1
  57. package/src/ensure_buffer.ts +2 -1
  58. package/src/error.ts +13 -0
  59. package/src/extended_json.ts +13 -5
  60. package/src/int_32.ts +5 -2
  61. package/src/objectid.ts +40 -43
  62. package/src/parser/deserializer.ts +65 -53
  63. package/src/parser/serializer.ts +13 -12
  64. package/src/parser/utils.ts +0 -8
  65. package/src/regexp.ts +14 -2
  66. package/src/symbol.ts +0 -2
  67. package/src/uuid.ts +4 -4
  68. package/src/uuid_utils.ts +2 -1
package/bower.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "test",
23
23
  "tools"
24
24
  ],
25
- "version": "4.5.0"
25
+ "version": "4.5.4"
26
26
  }
package/bson.d.ts CHANGED
@@ -20,6 +20,10 @@ export declare class Binary {
20
20
  static readonly SUBTYPE_UUID = 4;
21
21
  /** MD5 BSON type */
22
22
  static readonly SUBTYPE_MD5 = 5;
23
+ /** Encrypted BSON type */
24
+ static readonly SUBTYPE_ENCRYPTED = 6;
25
+ /** Column BSON type */
26
+ static readonly SUBTYPE_COLUMN = 7;
23
27
  /** User BSON type */
24
28
  static readonly SUBTYPE_USER_DEFINED = 128;
25
29
  buffer: Buffer;
@@ -59,10 +63,10 @@ export declare class Binary {
59
63
  value(asRaw?: boolean): string | BinarySequence;
60
64
  /** the length of the binary sequence */
61
65
  length(): number;
62
- /* Excluded from this release type: toJSON */
63
- /* Excluded from this release type: toString */
66
+ toJSON(): string;
67
+ toString(format?: string): string;
64
68
  /* Excluded from this release type: toExtendedJSON */
65
- /* Excluded from this release type: toUUID */
69
+ toUUID(): UUID;
66
70
  /* Excluded from this release type: fromExtendedJSON */
67
71
  inspect(): string;
68
72
  }
@@ -112,10 +116,14 @@ declare const BSON: {
112
116
  deserialize: typeof deserialize;
113
117
  calculateObjectSize: typeof calculateObjectSize;
114
118
  deserializeStream: typeof deserializeStream;
119
+ BSONError: typeof BSONError;
120
+ BSONTypeError: typeof BSONTypeError;
115
121
  };
116
122
  export default BSON;
117
123
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_BYTE_ARRAY */
124
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_COLUMN */
118
125
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */
126
+ /* Excluded from this release type: BSON_BINARY_SUBTYPE_ENCRYPTED */
119
127
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_FUNCTION */
120
128
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_MD5 */
121
129
  /* Excluded from this release type: BSON_BINARY_SUBTYPE_USER_DEFINED */
@@ -146,6 +154,10 @@ export default BSON;
146
154
  /* Excluded from this release type: BSON_INT32_MIN */
147
155
  /* Excluded from this release type: BSON_INT64_MAX */
148
156
  /* Excluded from this release type: BSON_INT64_MIN */
157
+ /** @public */
158
+ export declare class BSONError extends Error {
159
+ readonly name: string;
160
+ }
149
161
  /**
150
162
  * A class representation of the BSON RegExp type.
151
163
  * @public
@@ -186,11 +198,18 @@ export declare class BSONSymbol {
186
198
  constructor(value: string);
187
199
  /** Access the wrapped string value. */
188
200
  valueOf(): string;
201
+ toString(): string;
202
+ /* Excluded from this release type: inspect */
203
+ toJSON(): string;
189
204
  }
190
205
  /** @public */
191
206
  export declare interface BSONSymbolExtended {
192
207
  $symbol: string;
193
208
  }
209
+ /** @public */
210
+ export declare class BSONTypeError extends TypeError {
211
+ readonly name: string;
212
+ }
194
213
  /**
195
214
  * Calculate the bson size for a passed in Javascript object.
196
215
  *
@@ -214,7 +233,10 @@ export declare class Code {
214
233
  * @param scope - an optional scope for the function.
215
234
  */
216
235
  constructor(code: string | Function, scope?: Document);
217
- /* Excluded from this release type: toJSON */
236
+ toJSON(): {
237
+ code: string | Function;
238
+ scope?: Document;
239
+ };
218
240
  /* Excluded from this release type: toExtendedJSON */
219
241
  /* Excluded from this release type: fromExtendedJSON */
220
242
  inspect(): string;
@@ -242,7 +264,7 @@ export declare class DBRef {
242
264
  constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);
243
265
  /* Excluded from this release type: namespace */
244
266
  /* Excluded from this release type: namespace */
245
- /* Excluded from this release type: toJSON */
267
+ toJSON(): DBRefLike & Document;
246
268
  /* Excluded from this release type: toExtendedJSON */
247
269
  /* Excluded from this release type: fromExtendedJSON */
248
270
  inspect(): string;
@@ -354,7 +376,8 @@ export declare class Double {
354
376
  * @returns returns the wrapped double number.
355
377
  */
356
378
  valueOf(): number;
357
- /* Excluded from this release type: toJSON */
379
+ toJSON(): number;
380
+ toString(radix?: number): string;
358
381
  /* Excluded from this release type: toExtendedJSON */
359
382
  /* Excluded from this release type: fromExtendedJSON */
360
383
  inspect(): string;
@@ -458,7 +481,8 @@ export declare class Int32 {
458
481
  * @returns returns the wrapped int32 number.
459
482
  */
460
483
  valueOf(): number;
461
- /* Excluded from this release type: toJSON */
484
+ toString(radix?: number): string;
485
+ toJSON(): number;
462
486
  /* Excluded from this release type: toExtendedJSON */
463
487
  /* Excluded from this release type: fromExtendedJSON */
464
488
  inspect(): string;
@@ -839,9 +863,9 @@ declare class ObjectId {
839
863
  /**
840
864
  * Create an ObjectId type
841
865
  *
842
- * @param id - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
866
+ * @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
843
867
  */
844
- constructor(id?: string | Buffer | number | ObjectIdLike | ObjectId);
868
+ constructor(inputId?: string | Buffer | number | ObjectIdLike | ObjectId);
845
869
  /*
846
870
  * The ObjectId bytes
847
871
  * @readonly
@@ -861,8 +885,14 @@ declare class ObjectId {
861
885
  * @param time - pass in a second based timestamp.
862
886
  */
863
887
  static generate(time?: number): Buffer;
864
- /* Excluded from this release type: toString */
865
- /* Excluded from this release type: toJSON */
888
+ /**
889
+ * Converts the id into a 24 character hex string for printing
890
+ *
891
+ * @param format - The Buffer toString format parameter.
892
+ */
893
+ toString(format?: string): string;
894
+ /** Converts to its JSON the 24 character hex string representation. */
895
+ toJSON(): string;
866
896
  /**
867
897
  * Compares the equality of this ObjectId with `otherID`.
868
898
  *
@@ -1026,8 +1056,15 @@ export declare class UUID {
1026
1056
  * @param includeDashes - should the string exclude dash-separators.
1027
1057
  * */
1028
1058
  toHexString(includeDashes?: boolean): string;
1029
- /* Excluded from this release type: toString */
1030
- /* Excluded from this release type: toJSON */
1059
+ /**
1060
+ * Converts the id into a 36 character (dashes included) hex string, unless a encoding is specified.
1061
+ */
1062
+ toString(encoding?: string): string;
1063
+ /**
1064
+ * Converts the id into its JSON string representation.
1065
+ * A 36 character (dashes included) hex string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1066
+ */
1067
+ toJSON(): string;
1031
1068
  /**
1032
1069
  * Compares the equality of this UUID with `otherID`.
1033
1070
  *