foxts 4.2.1 → 4.3.0
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/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
|
@@ -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.0",
|
|
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};
|