foxts 4.2.1 → 4.3.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/fnv1a/index.d.ts +4 -2
- package/dist/fnv1a/index.js +1 -1
- package/dist/fnv1a/index.mjs +1 -1
- package/dist/fnv1a52/index.d.ts +8 -2
- package/dist/fnv1a52/index.js +1 -1
- package/dist/fnv1a52/index.mjs +1 -1
- package/dist/simple-string-hash/index.js +1 -1
- package/dist/simple-string-hash/index.mjs +1 -1
- package/dist/ts-xor/index.d.ts +35 -0
- package/dist/ts-xor/index.js +1 -0
- package/dist/ts-xor/index.mjs +0 -0
- package/dist/wait-for/index.d.ts +12 -0
- package/dist/wait-for/index.js +1 -0
- package/dist/wait-for/index.mjs +1 -0
- package/package.json +14 -6
- package/dist/wait-until/index.d.ts +0 -12
- package/dist/wait-until/index.js +0 -1
- package/dist/wait-until/index.mjs +0 -1
package/dist/fnv1a/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
declare function fnv1a(
|
|
1
|
+
declare function fnv1a(str: string): number;
|
|
2
|
+
declare const __internal_hl_do_not_use__: string[];
|
|
3
|
+
declare function fnv1ahex(str: string): string;
|
|
2
4
|
|
|
3
|
-
export { fnv1a };
|
|
5
|
+
export { __internal_hl_do_not_use__, fnv1a, fnv1ahex };
|
package/dist/fnv1a/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.fnv1a=function(t){let e=
|
|
1
|
+
"use strict";const t=Array(256);for(let r=0;r<256;r++)t[r]=(r>>4&15).toString(16)+(15&r).toString(16);exports.__internal_hl_do_not_use__=t,exports.fnv1a=function(t){const r=t.length-3;let o=0,e=0,n=40389,c=33052;for(;o<r;)n^=t.charCodeAt(o++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(o++)),c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;for(;o<r+3;)n^=t.charCodeAt(o++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;return(c<<16>>>0)+n},exports.fnv1ahex=function(r){const o=r.length-3;let e=0,n=0,c=40389,a=33052;for(;e<o;)c^=r.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^r.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;for(;e<o+3;)c^=r.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;return t[a>>>8&255]+t[255&a]+t[c>>>8&255]+t[255&c]};
|
package/dist/fnv1a/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let e=
|
|
1
|
+
function t(t){const o=t.length-3;let r=0,e=0,n=40389,c=33052;for(;r<o;)n^=t.charCodeAt(r++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,e=403*(n=65535&e^t.charCodeAt(r++)),c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;for(;r<o+3;)n^=t.charCodeAt(r++),e=403*n,c=403*c+(n<<8)+(e>>>16)&65535,n=65535&e;return(c<<16>>>0)+n}const o=Array(256);for(let t=0;t<256;t++)o[t]=(t>>4&15).toString(16)+(15&t).toString(16);const r=o;function e(t){const r=t.length-3;let e=0,n=0,c=40389,a=33052;for(;e<r;)c^=t.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,n=403*(c=65535&n^t.charCodeAt(e++)),a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;for(;e<r+3;)c^=t.charCodeAt(e++),n=403*c,a=403*a+(c<<8)+(n>>>16)&65535,c=65535&n;return o[a>>>8&255]+o[255&a]+o[c>>>8&255]+o[255&c]}export{r as __internal_hl_do_not_use__,t as fnv1a,e as fnv1ahex};
|
package/dist/fnv1a52/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FNV-1a Hash implementation
|
|
3
|
+
*
|
|
4
|
+
* @author Sukka (sukkaw) <https://skk.moe>
|
|
3
5
|
* @author Travis Webb (tjwebb) <me@traviswebb.com>
|
|
4
6
|
*
|
|
5
|
-
*
|
|
7
|
+
* @description
|
|
6
8
|
*
|
|
9
|
+
* Ported from https://github.com/tjwebb/fnv-plus/blob/master/index.js
|
|
7
10
|
* Simplified, optimized and add modified for 52 bit, which provides a larger hash space
|
|
8
11
|
* and still making use of Javascript's 53-bit integer space.
|
|
12
|
+
*
|
|
13
|
+
* DO NOT USE toString(16) here! Use `fnv1a52hex` instead, way faster
|
|
9
14
|
*/
|
|
10
15
|
declare function fnv1a52(str: string): number;
|
|
16
|
+
declare function fnv1a52hex(str: string): string;
|
|
11
17
|
|
|
12
|
-
export { fnv1a52 };
|
|
18
|
+
export { fnv1a52, fnv1a52hex };
|
package/dist/fnv1a52/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.fnv1a52=function(
|
|
1
|
+
"use strict";var _=require("../fnv1a/index.js");const n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];exports.fnv1a52=function(_){const n=_.length;let t=0,e=0,o=8997,r=0,l=33826,s=0,a=40164,u=0,h=52210;for(;t<n;)o^=_.charCodeAt(t++),e=435*o,r=435*l,s=435*a,u=435*h,s+=o<<8,u+=l<<8,r+=e>>>16,o=65535&e,s+=r>>>16,l=65535&r,h=u+(s>>>16)&65535,a=65535&s;return(15&h)*0x1000000000000+0x100000000*a+65536*l+(o^h>>4)},exports.fnv1a52hex=function(t){const e=t.length;let o=0,r=0,l=8997,s=0,a=33826,u=0,h=40164,i=0,d=52210;for(;o<e;)l^=t.charCodeAt(o++),r=435*l,s=435*a,u=435*h,i=435*d,u+=l<<8,i+=a<<8,s+=r>>>16,l=65535&r,u+=s>>>16,a=65535&s,d=i+(u>>>16)&65535,h=65535&u;return n[15&d]+_.__internal_hl_do_not_use__[h>>8]+_.__internal_hl_do_not_use__[255&h]+_.__internal_hl_do_not_use__[a>>8]+_.__internal_hl_do_not_use__[255&a]+_.__internal_hl_do_not_use__[l>>8^d>>12]+_.__internal_hl_do_not_use__[(l^d>>4)&255]};
|
package/dist/fnv1a52/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(
|
|
1
|
+
import{__internal_hl_do_not_use__ as n}from"../fnv1a/index.mjs";function t(n){const t=n.length;let e=0,o=0,r=8997,f=0,c=33826,a=0,h=40164,x=0,d=52210;for(;e<t;)r^=n.charCodeAt(e++),o=435*r,f=435*c,a=435*h,x=435*d,a+=r<<8,x+=c<<8,f+=o>>>16,r=65535&o,a+=f>>>16,c=65535&f,d=x+(a>>>16)&65535,h=65535&a;return(15&d)*0x1000000000000+0x100000000*h+65536*c+(r^d>>4)}const e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(t){const o=t.length;let r=0,f=0,c=8997,a=0,h=33826,x=0,d=40164,i=0,l=52210;for(;r<o;)c^=t.charCodeAt(r++),f=435*c,a=435*h,x=435*d,i=435*l,x+=c<<8,i+=h<<8,a+=f>>>16,c=65535&f,x+=a>>>16,h=65535&a,l=i+(x>>>16)&65535,d=65535&x;return e[15&l]+n[d>>8]+n[255&d]+n[h>>8]+n[255&h]+n[c>>8^l>>12]+n[(c^l>>4)&255]}export{t as fnv1a52,o as fnv1a52hex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("../fnv1a52/index.js");require("../fnv1a/index.js"),exports.simpleStringHash=function(r){return n.fnv1a52(r).toString(36)+r.length.toString(36)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fnv1a52 as
|
|
1
|
+
import{fnv1a52 as n}from"../fnv1a52/index.mjs";import"../fnv1a/index.mjs";function t(t){return n(t).toString(36)+t.length.toString(36)}export{t as simpleStringHash};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skip evaluating `U` if `T` is `unknown`.
|
|
3
|
+
*/
|
|
4
|
+
type EvalIfNotUnknown<T, U> = unknown extends T ? never : U;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve mapped types and show the derived keys and their types when hovering in
|
|
7
|
+
* VS Code, instead of just showing the names those mapped types are defined with.
|
|
8
|
+
*/
|
|
9
|
+
type Prettify<T> = {
|
|
10
|
+
[K in keyof T]: T[K];
|
|
11
|
+
} & {};
|
|
12
|
+
/**
|
|
13
|
+
* Get the keys of T without any keys of U.
|
|
14
|
+
*/
|
|
15
|
+
type Without<T, U> = {
|
|
16
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Restrict using either exclusively the keys of `T` or exclusively the keys of `U`.
|
|
21
|
+
*
|
|
22
|
+
* No unique keys of `T` can be used simultaneously with any unique keys of `U`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const myVar: XOR<{ data: object }, { error: object }>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Supports from 2 up to 8 generic parameters.
|
|
30
|
+
*
|
|
31
|
+
* More: https://github.com/maninak/ts-xor/tree/master#description
|
|
32
|
+
* */
|
|
33
|
+
type XOR<A, B, C = unknown, D = unknown, E = unknown, F = unknown, G = unknown, H = unknown> = Prettify<(Without<B & C & D & E & F & G & H, A> & A) | (Without<A & C & D & E & F & G & H, B> & B) | EvalIfNotUnknown<C, Without<A & B & D & E & F & G & H, C> & C> | EvalIfNotUnknown<D, Without<A & B & C & E & F & G & H, D> & D> | EvalIfNotUnknown<E, Without<A & B & C & D & F & G & H, E> & E> | EvalIfNotUnknown<F, Without<A & B & C & D & E & G & H, F> & F> | EvalIfNotUnknown<G, Without<A & B & C & D & E & F & H, G> & G> | EvalIfNotUnknown<H, Without<A & B & C & D & E & F & G, H> & H>>;
|
|
34
|
+
|
|
35
|
+
export type { XOR };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type FalsyValue = null | undefined | false | '' | 0 | void;
|
|
2
|
+
type TruthyValue = object | unknown[] | symbol | Function | Exclude<number, 0> | Exclude<string, ''> | true;
|
|
3
|
+
type CleanupFn = () => void;
|
|
4
|
+
type OnCleanup = (cleanUpFn: CleanupFn) => void;
|
|
5
|
+
type Scheduler = (callback: () => Promise<void>, onCleanup: OnCleanup) => void | CleanupFn;
|
|
6
|
+
type Predicate<T extends TruthyValue> = () => T | FalsyValue | Promise<T> | Promise<FalsyValue>;
|
|
7
|
+
declare function waitFor<T extends TruthyValue>(predicate: Predicate<T>, scheduler: Scheduler, abortSignal?: AbortSignal | null): Promise<T>;
|
|
8
|
+
declare function waitFor<T extends TruthyValue>(predicate: Predicate<T>, checkInterval?: number, abortSignal?: AbortSignal | null): Promise<T>;
|
|
9
|
+
declare function waitFor<T extends TruthyValue>(predicate: Predicate<T>, abortSignal: AbortSignal): Promise<T>;
|
|
10
|
+
|
|
11
|
+
export { waitFor };
|
|
12
|
+
export type { CleanupFn, OnCleanup, Predicate, Scheduler };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.waitFor=function(t,o=50,e=null){if("object"==typeof o&&"aborted"in o&&(e=o,o=50),"number"==typeof o){const t=o;o=(o,e)=>{const n=setTimeout(o,t);e(()=>clearTimeout(n))}}e??=AbortSignal.timeout(5e3);const n=new Set,r=t=>n.add(t);return new Promise((c,i)=>{const a=async()=>{try{e.throwIfAborted();const i=await t();if(i)return void c(i);const s=o(a,r);"function"==typeof s&&n.add(s)}catch(t){i(t)}};a()}).finally(()=>{n.forEach(t=>t())})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(o,e=50,n=null){if("object"==typeof e&&"aborted"in e&&(n=e,e=50),"number"==typeof e){const t=e;e=(o,e)=>{const n=setTimeout(o,t);e(()=>clearTimeout(n))}}n??=AbortSignal.timeout(5e3);const r=new Set,c=t=>r.add(t);return new Promise((t,i)=>{const a=async()=>{try{n.throwIfAborted();const i=await o();if(i)return void t(i);const f=e(a,c);"function"==typeof f&&r.add(f)}catch(t){i(t)}};a()}).finally(()=>{r.forEach(t=>t())})}export{t as waitFor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foxts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Opinionated collection of common TypeScript utils by @SukkaW",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/SukkaW/foxts"
|
|
@@ -274,6 +274,12 @@
|
|
|
274
274
|
"require": "./dist/text-line-stream/index.js",
|
|
275
275
|
"default": "./dist/text-line-stream/index.js"
|
|
276
276
|
},
|
|
277
|
+
"./ts-xor": {
|
|
278
|
+
"types": "./dist/ts-xor/index.d.ts",
|
|
279
|
+
"import": "./dist/ts-xor/index.mjs",
|
|
280
|
+
"require": "./dist/ts-xor/index.js",
|
|
281
|
+
"default": "./dist/ts-xor/index.js"
|
|
282
|
+
},
|
|
277
283
|
"./uint8array-utils": {
|
|
278
284
|
"types": "./dist/uint8array-utils/index.d.ts",
|
|
279
285
|
"import": "./dist/uint8array-utils/index.mjs",
|
|
@@ -286,11 +292,11 @@
|
|
|
286
292
|
"require": "./dist/wait/index.js",
|
|
287
293
|
"default": "./dist/wait/index.js"
|
|
288
294
|
},
|
|
289
|
-
"./wait-
|
|
290
|
-
"types": "./dist/wait-
|
|
291
|
-
"import": "./dist/wait-
|
|
292
|
-
"require": "./dist/wait-
|
|
293
|
-
"default": "./dist/wait-
|
|
295
|
+
"./wait-for": {
|
|
296
|
+
"types": "./dist/wait-for/index.d.ts",
|
|
297
|
+
"import": "./dist/wait-for/index.mjs",
|
|
298
|
+
"require": "./dist/wait-for/index.js",
|
|
299
|
+
"default": "./dist/wait-for/index.js"
|
|
294
300
|
}
|
|
295
301
|
},
|
|
296
302
|
"sideEffects": false,
|
|
@@ -336,10 +342,12 @@
|
|
|
336
342
|
"rollup-plugin-oxc-resolve": "^0.0.4",
|
|
337
343
|
"rollup-plugin-swc3": "^0.12.1",
|
|
338
344
|
"sinon": "^21.0.0",
|
|
345
|
+
"typescript": "^5.9.3",
|
|
339
346
|
"word-list": "3.0.0"
|
|
340
347
|
},
|
|
341
348
|
"scripts": {
|
|
342
349
|
"lint": "eslint --format=sukka .",
|
|
350
|
+
"build-ts-xor": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./src/ts-xor/_build.ts",
|
|
343
351
|
"test": "SWC_NODE_IGNORE_DYNAMIC=1 SWC_NODE_INLINE_SOURCE_MAP=1 nyc mocha --require @swc-node/register --parallel --full-trace ./src/**/*.test.ts",
|
|
344
352
|
"bench": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register",
|
|
345
353
|
"bench:all": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./src/**/*.bench.ts",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type FalsyValue = null | undefined | false | '' | 0 | void;
|
|
2
|
-
type TruthyValue = Record<string, unknown> | unknown[] | symbol | ((..._args: unknown[]) => unknown) | Exclude<number, 0> | Exclude<string, ''> | true;
|
|
3
|
-
type CleanupFn = () => void;
|
|
4
|
-
type OnCleanup = (cleanUpFn: CleanupFn) => void;
|
|
5
|
-
type Scheduler = (callback: () => Promise<void>, onCleanup: OnCleanup) => void | CleanupFn;
|
|
6
|
-
type Predicate<T extends TruthyValue | FalsyValue> = () => T | Promise<T>;
|
|
7
|
-
declare function waitUntil<T extends TruthyValue | FalsyValue>(predicate: Predicate<T>, scheduler: Scheduler, abortSignal?: AbortSignal | null): Promise<T>;
|
|
8
|
-
declare function waitUntil<T extends TruthyValue | FalsyValue>(predicate: Predicate<T>, checkInterval?: number, abortSignal?: AbortSignal | null): Promise<T>;
|
|
9
|
-
declare function waitUntil<T extends TruthyValue | FalsyValue>(predicate: Predicate<T>, abortSignal: AbortSignal): Promise<T>;
|
|
10
|
-
|
|
11
|
-
export { waitUntil };
|
|
12
|
-
export type { CleanupFn, OnCleanup, Predicate, Scheduler };
|
package/dist/wait-until/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";exports.waitUntil=function(t,o=50,e=null){if("object"==typeof o&&"aborted"in o&&(e=o,o=50),"number"==typeof o){const t=o;o=(o,e)=>{const n=setTimeout(o,t);e(()=>clearTimeout(n))}}e??=AbortSignal.timeout(5e3);const n=new Set,r=t=>n.add(t);return new Promise((i,c)=>{const a=async()=>{try{e.throwIfAborted();const c=await t();if(c)return void i(c);const s=o(a,r);"function"==typeof s&&n.add(s)}catch(t){c(t)}};a()}).finally(()=>{n.forEach(t=>t())})};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(o,e=50,n=null){if("object"==typeof e&&"aborted"in e&&(n=e,e=50),"number"==typeof e){const t=e;e=(o,e)=>{const n=setTimeout(o,t);e(()=>clearTimeout(n))}}n??=AbortSignal.timeout(5e3);const r=new Set,i=t=>r.add(t);return new Promise((t,c)=>{const a=async()=>{try{n.throwIfAborted();const c=await o();if(c)return void t(c);const f=e(a,i);"function"==typeof f&&r.add(f)}catch(t){c(t)}};a()}).finally(()=>{r.forEach(t=>t())})}export{t as waitUntil};
|