compact-encoding
Advanced tools
+17
-3
@@ -174,3 +174,5 @@ const b4a = require('b4a') | ||
| if (state.end - state.start < 7) throw new Error('Out of bounds') | ||
| return uint24.decode(state) + 0x1000000 * uint32.decode(state) | ||
| return validateSafeUint( | ||
| uint24.decode(state) + 0x1000000 * uint32.decode(state) | ||
| ) | ||
| } | ||
@@ -191,3 +193,5 @@ }) | ||
| if (state.end - state.start < 8) throw new Error('Out of bounds') | ||
| return uint32.decode(state) + 0x100000000 * uint32.decode(state) | ||
| return validateSafeUint( | ||
| uint32.decode(state) + 0x100000000 * uint32.decode(state) | ||
| ) | ||
| } | ||
@@ -208,3 +212,5 @@ }) | ||
| if (state.end - state.start < 8) throw new Error('Out of bounds') | ||
| return 0x100000000 * uint32be.decode(state) + uint32be.decode(state) | ||
| return validateSafeUint( | ||
| 0x100000000 * uint32be.decode(state) + uint32be.decode(state) | ||
| ) | ||
| } | ||
@@ -1091,2 +1097,10 @@ } | ||
| function validateSafeUint(n) { | ||
| if (n > Number.MAX_SAFE_INTEGER) | ||
| throw new Error( | ||
| 'uint is greater than the maximum safe integer, use biguint/bigint' | ||
| ) | ||
| return n | ||
| } | ||
| function validateUint(n) { | ||
@@ -1093,0 +1107,0 @@ if (n >= 0 === false /* Handles NaN as well */) |
+1
-1
| { | ||
| "name": "compact-encoding", | ||
| "version": "3.2.0", | ||
| "version": "3.3.0", | ||
| "description": "A series of compact encoding schemes for building small and fast parsers and serializers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
53860
0.51%1260
1.04%