ordered-binary
Advanced tools
Comparing version 1.4.0 to 1.4.1
35
index.js
@@ -68,3 +68,3 @@ /* | ||
if (target.utf8Write) | ||
position += target.utf8Write(key, position) | ||
position += target.utf8Write(key, position, 0xffffffff) | ||
else | ||
@@ -288,6 +288,6 @@ position += textEncoder.encodeInto(key, target.subarray(position)).written | ||
if (pendingSurrogate) { | ||
byte1 = pendingSurrogate | ||
pendingSurrogate = null | ||
position += 3 | ||
return byte1 | ||
byte1 = pendingSurrogate | ||
pendingSurrogate = null | ||
position += 3 | ||
return byte1 | ||
} | ||
@@ -299,6 +299,5 @@ const byte2 = src[position++] & 0x3f | ||
if (unit > 0xffff) { | ||
unit -= 0x10000 | ||
unit = 0xdc00 | (unit & 0x3ff) | ||
pendingSurrogate = ((unit >>> 10) & 0x3ff) | 0xd800 | ||
position -= 4 // reset so we can return the next part of the surrogate pair | ||
pendingSurrogate = 0xdc00 | (unit & 0x3ff) | ||
unit = (((unit - 0x10000) >>> 10) & 0x3ff) | 0xd800 | ||
position -= 4 // reset so we can return the next part of the surrogate pair | ||
} | ||
@@ -311,3 +310,19 @@ return unit | ||
const readString = eval(makeStringBuilder()) | ||
const readString = | ||
typeof process !== 'undefined' && process.isBun ? // the eval in bun doesn't properly closure on position, so we | ||
// have to manually update it | ||
(function(reading) { | ||
let { setPosition, getPosition, readString } = reading; | ||
return (source) => { | ||
setPosition(position); | ||
let value = readString(source); | ||
position = getPosition(); | ||
return value; | ||
}; | ||
})((new Function('fromCharCode', 'let position; let readString = ' + makeStringBuilder() + | ||
';return {' + | ||
'setPosition(p) { position = p },' + | ||
'getPosition() { return position },' + | ||
'readString }'))(fromCharCode)) : | ||
eval(makeStringBuilder()) | ||
@@ -314,0 +329,0 @@ export function compareKeys(a, b) { |
{ | ||
"name": "ordered-binary", | ||
"author": "Kris Zyp", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Conversion of JavaScript primitives to and from Buffer with binary order matching natural primitive order", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -49,2 +49,3 @@ import { assert } from 'chai' | ||
assert.strictEqual(fromBufferKey(toBufferKey('\x03test\x01\x00')), '\x03test\x01\x00') | ||
assert.strictEqual(fromBufferKey(toBufferKey('prance 🧚🏻♀️🩷')), 'prance 🧚🏻♀️🩷') | ||
}) | ||
@@ -51,0 +52,0 @@ test('string comparison', () => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52253
14
898