@andrew_l/toolkit 0.3.4 → 0.3.6
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 +51 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.mts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.mjs +49 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -832,7 +832,7 @@ function uniqBy(array, comparator) {
|
|
|
832
832
|
});
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
class
|
|
835
|
+
class AssertionError extends Error {
|
|
836
836
|
/**
|
|
837
837
|
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
|
838
838
|
*/
|
|
@@ -863,17 +863,6 @@ class BrowserAssertionError extends Error {
|
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
865
|
|
|
866
|
-
let AssertionError = BrowserAssertionError;
|
|
867
|
-
if (isNode()) {
|
|
868
|
-
try {
|
|
869
|
-
const assert = require("node:assert");
|
|
870
|
-
if (assert.AssertionError) {
|
|
871
|
-
AssertionError = assert.AssertionError;
|
|
872
|
-
}
|
|
873
|
-
} catch {
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
866
|
function ok(value, message) {
|
|
878
867
|
if (!value) {
|
|
879
868
|
throw toError$1(
|
|
@@ -1825,8 +1814,13 @@ function bitPack(options) {
|
|
|
1825
1814
|
function initFields(fields) {
|
|
1826
1815
|
return fields.map((field) => {
|
|
1827
1816
|
if (field.bits > 32) {
|
|
1817
|
+
ok(
|
|
1818
|
+
field.take === "low",
|
|
1819
|
+
`Fields more than 32 bits with take 'high' not yet supported`
|
|
1820
|
+
);
|
|
1821
|
+
const highMask = Math.pow(2, field.bits - 32) - 1;
|
|
1828
1822
|
return [
|
|
1829
|
-
`var ${field.id}_high = (data['${field.name}'] / 0x100000000) | 0;`,
|
|
1823
|
+
`var ${field.id}_high = ((data['${field.name}'] / 0x100000000) | 0) & 0x${highMask.toString(16)};`,
|
|
1830
1824
|
`var ${field.id}_low = (data['${field.name}'] >>> 0);`
|
|
1831
1825
|
].join("\n");
|
|
1832
1826
|
}
|
|
@@ -2188,6 +2182,47 @@ function concatenateBytes(a, b) {
|
|
|
2188
2182
|
return result;
|
|
2189
2183
|
}
|
|
2190
2184
|
|
|
2185
|
+
function rleDecode(buf, value = 0) {
|
|
2186
|
+
const result = [];
|
|
2187
|
+
let i = 0;
|
|
2188
|
+
while (i < buf.length) {
|
|
2189
|
+
if (buf[i] === value) {
|
|
2190
|
+
const count = buf[i + 1];
|
|
2191
|
+
for (let j = 0; j < count; j++) {
|
|
2192
|
+
result.push(value);
|
|
2193
|
+
}
|
|
2194
|
+
i += 2;
|
|
2195
|
+
} else {
|
|
2196
|
+
result.push(buf[i]);
|
|
2197
|
+
i++;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return new Uint8Array(result);
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
function rleEncode(buf, value = 0) {
|
|
2204
|
+
const result = [];
|
|
2205
|
+
let i = 0;
|
|
2206
|
+
while (i < buf.length) {
|
|
2207
|
+
if (buf[i] === value) {
|
|
2208
|
+
const runStart = i;
|
|
2209
|
+
while (i < buf.length && buf[i] === value) {
|
|
2210
|
+
i++;
|
|
2211
|
+
}
|
|
2212
|
+
let runLength = i - runStart;
|
|
2213
|
+
while (runLength > 0) {
|
|
2214
|
+
const chunk = Math.min(runLength, 255);
|
|
2215
|
+
result.push(value, chunk);
|
|
2216
|
+
runLength -= chunk;
|
|
2217
|
+
}
|
|
2218
|
+
} else {
|
|
2219
|
+
result.push(buf[i]);
|
|
2220
|
+
i++;
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
return new Uint8Array(result);
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2191
2226
|
function uint16ToUint8(value) {
|
|
2192
2227
|
const uint8Array = new Uint8Array(value.length * 2);
|
|
2193
2228
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -6006,8 +6041,8 @@ function withResolve(fn, getCacheKey) {
|
|
|
6006
6041
|
}
|
|
6007
6042
|
|
|
6008
6043
|
exports.AppError = AppError;
|
|
6044
|
+
exports.AssertionError = AssertionError;
|
|
6009
6045
|
exports.AsyncIterableQueue = AsyncIterableQueue;
|
|
6010
|
-
exports.BrowserAssertionError = BrowserAssertionError;
|
|
6011
6046
|
exports.CancellablePromise = CancellablePromise;
|
|
6012
6047
|
exports.ColorParser = ColorParser;
|
|
6013
6048
|
exports.EJSON = instance;
|
|
@@ -6193,6 +6228,8 @@ exports.randomString = randomString;
|
|
|
6193
6228
|
exports.removeVS16s = removeVS16s;
|
|
6194
6229
|
exports.retryOnError = retryOnError;
|
|
6195
6230
|
exports.rgbToChannels = rgbToChannels;
|
|
6231
|
+
exports.rleDecode = rleDecode;
|
|
6232
|
+
exports.rleEncode = rleEncode;
|
|
6196
6233
|
exports.round2digits = round2digits;
|
|
6197
6234
|
exports.secondsToHm = secondsToHm;
|
|
6198
6235
|
exports.set = set;
|