protobufjs 8.3.0 → 8.4.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/index.d.ts CHANGED
@@ -1851,7 +1851,7 @@ export interface IConversionOptions {
1851
1851
 
1852
1852
  /**
1853
1853
  * Long conversion type.
1854
- * Valid values are `String` and `Number` (the global types).
1854
+ * Valid values are `BigInt`, `String` and `Number` (the global types).
1855
1855
  * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
1856
1856
  */
1857
1857
  longs?: Function;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protobufjs",
3
- "version": "8.3.0",
3
+ "version": "8.4.0",
4
4
  "versionScheme": "~",
5
5
  "description": "Protocol Buffers for JavaScript & TypeScript.",
6
6
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
@@ -46,7 +46,7 @@
46
46
  "make": "npm run lint:sources && npm run build && npm run lint:types && node ./scripts/gentests.js && npm test"
47
47
  },
48
48
  "dependencies": {
49
- "long": "^5.0.0"
49
+ "long": "^5.3.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@eslint/js": "^10.0.0",
package/src/converter.js CHANGED
@@ -209,7 +209,9 @@ function genValuePartial_toObject(gen, field, fieldIndex, dstProp, srcProp) {
209
209
  case "sint64":
210
210
  case "fixed64":
211
211
  case "sfixed64": gen
212
- ("if(typeof m%s===\"number\")", srcProp)
212
+ ("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
213
+ ("d%s=typeof m%s===\"number\"?BigInt(m%s):util.Long.fromBits(m%s.low>>>0,m%s.high>>>0,%j).toBigInt()", dstProp, srcProp, srcProp, srcProp, srcProp, isUnsigned)
214
+ ("else if(typeof m%s===\"number\")", srcProp)
213
215
  ("d%s=o.longs===String?String(m%s):m%s", dstProp, srcProp, srcProp)
214
216
  ("else") // Long-like
215
217
  ("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", dstProp, srcProp, srcProp, srcProp, isUnsigned ? "true": "", srcProp);
@@ -277,9 +279,9 @@ converter.toObject = function toObject(mtype) {
277
279
  else if (field.long) gen
278
280
  ("if(util.Long){")
279
281
  ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
280
- ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
282
+ ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
281
283
  ("}else")
282
- ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
284
+ ("d%s=o.longs===String?%j:typeof BigInt!==\"undefined\"&&o.longs===BigInt?BigInt(%j):%i", prop, field.typeDefault.toString(), field.typeDefault.toString(), field.typeDefault.toNumber());
283
285
  else if (field.bytes) {
284
286
  var arrayDefault = Array.prototype.slice.call(field.typeDefault);
285
287
  gen
package/src/type.js CHANGED
@@ -585,7 +585,7 @@ Type.prototype.fromObject = function fromObject(object) { // eslint-disable-line
585
585
  * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
586
586
  * @interface IConversionOptions
587
587
  * @property {Function} [longs] Long conversion type.
588
- * Valid values are `String` and `Number` (the global types).
588
+ * Valid values are `BigInt`, `String` and `Number` (the global types).
589
589
  * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
590
590
  * @property {Function} [enums] Enum value conversion type.
591
591
  * Only valid value is `String` (the global type).
package/src/util/pool.js CHANGED
@@ -16,7 +16,7 @@ module.exports = pool;
16
16
  * @param {number} start Start offset
17
17
  * @param {number} end End offset
18
18
  * @returns {Uint8Array} Buffer slice
19
- * @this {Uint8Array}
19
+ * @this Uint8Array
20
20
  */
21
21
 
22
22
  /**