ordered-binary 1.6.0 → 1.6.1
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/dist/index.cjs +6 -1
- package/index.js +6 -1
- package/package.json +1 -1
- package/tests/test.js +2 -0
package/dist/index.cjs
CHANGED
|
@@ -212,7 +212,12 @@ function readKey(buffer, start, end, inSequence) {
|
|
|
212
212
|
let size = end - position;
|
|
213
213
|
let lowInt;
|
|
214
214
|
if (size > 4) {
|
|
215
|
-
lowInt = dataView.getInt32(position + 4)
|
|
215
|
+
lowInt = position + 8 <= buffer.length ? dataView.getInt32(position + 4) : (
|
|
216
|
+
buffer[position + 4] << 24 |
|
|
217
|
+
buffer[position + 5] << 16 |
|
|
218
|
+
buffer[position + 6] << 8 |
|
|
219
|
+
buffer[position + 7]
|
|
220
|
+
);
|
|
216
221
|
highInt |= lowInt >>> 28;
|
|
217
222
|
if (size <= 6) { // clear the last bits
|
|
218
223
|
lowInt &= -0x10000;
|
package/index.js
CHANGED
|
@@ -208,7 +208,12 @@ export function readKey(buffer, start, end, inSequence) {
|
|
|
208
208
|
let size = end - position
|
|
209
209
|
let lowInt
|
|
210
210
|
if (size > 4) {
|
|
211
|
-
lowInt = dataView.getInt32(position + 4)
|
|
211
|
+
lowInt = position + 8 <= buffer.length ? dataView.getInt32(position + 4) : (
|
|
212
|
+
buffer[position + 4] << 24 |
|
|
213
|
+
buffer[position + 5] << 16 |
|
|
214
|
+
buffer[position + 6] << 8 |
|
|
215
|
+
buffer[position + 7]
|
|
216
|
+
)
|
|
212
217
|
highInt |= lowInt >>> 28
|
|
213
218
|
if (size <= 6) { // clear the last bits
|
|
214
219
|
lowInt &= -0x10000
|
package/package.json
CHANGED
package/tests/test.js
CHANGED
|
@@ -28,6 +28,8 @@ suite('key buffers', () => {
|
|
|
28
28
|
assert.strictEqual(fromBufferKey(toBufferKey(3.4)), 3.4)
|
|
29
29
|
assert.strictEqual(fromBufferKey(toBufferKey(Math.PI)), Math.PI)
|
|
30
30
|
assert.strictEqual(fromBufferKey(toBufferKey(2002225)), 2002225)
|
|
31
|
+
// check to make sure it works with a limited ArrayBuffer
|
|
32
|
+
assert.strictEqual(fromBufferKey(new Uint8Array(toBufferKey(2002225))), 2002225)
|
|
31
33
|
assert.strictEqual(fromBufferKey(toBufferKey(9377288)), 9377288)
|
|
32
34
|
assert.strictEqual(fromBufferKey(toBufferKey(1503579323825)), 1503579323825)
|
|
33
35
|
assert.strictEqual(fromBufferKey(toBufferKey(1503579323825.3523532)), 1503579323825.3523532)
|