@neovici/cosmoz-utils 6.25.0 → 6.25.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/function.d.ts +7 -1
- package/dist/function.js +8 -1
- package/dist/promise.d.ts +1 -1
- package/package.json +1 -1
package/dist/function.d.ts
CHANGED
|
@@ -6,5 +6,11 @@ export declare function constant(): () => undefined;
|
|
|
6
6
|
export declare function constant<T>(v: T): () => T;
|
|
7
7
|
export declare const constTrue: () => true, constUndefined: () => undefined, noop: () => undefined, identity: <T>(obj: T) => T, or: <A, F extends OrFn<A>>(...fns: F[]) => (...args: A[]) => boolean;
|
|
8
8
|
export declare const once: <A extends Arr, R, F extends OnceFn<A, R> = OnceFn<A, R>>(fn: F, check?: OnceCheckFn<A>) => (...args: A) => any;
|
|
9
|
-
|
|
9
|
+
type Invoked<F> = F extends (...args: any[]) => infer R ? R : F;
|
|
10
|
+
/**
|
|
11
|
+
* The args of a known function are checked against its tuple; for a
|
|
12
|
+
* value-or-function union the runtime dispatch decides the member, so
|
|
13
|
+
* the args cannot be typed.
|
|
14
|
+
*/
|
|
15
|
+
export declare const invoke: <F>(fn: F, ...args: F extends (...args: infer P) => unknown ? P : unknown[]) => Invoked<F>;
|
|
10
16
|
export {};
|
package/dist/function.js
CHANGED
|
@@ -6,4 +6,11 @@ export const once = (fn, check = constTrue) => {
|
|
|
6
6
|
let result;
|
|
7
7
|
return (...args) => (result ??= check(args) ? fn(...args) : undefined);
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The args of a known function are checked against its tuple; for a
|
|
11
|
+
* value-or-function union the runtime dispatch decides the member, so
|
|
12
|
+
* the args cannot be typed.
|
|
13
|
+
*/
|
|
14
|
+
export const invoke = (fn, ...args) => typeof fn === 'function'
|
|
15
|
+
? fn(...args)
|
|
16
|
+
: fn;
|
package/dist/promise.d.ts
CHANGED
|
@@ -29,5 +29,5 @@ export declare const debounce$: <T extends unknown[], P>(fn: (...args: T) => P |
|
|
|
29
29
|
export declare const share$: <T extends unknown[], P>(fn: (...args: T) => P | PromiseLike<P>) => (...args: T) => Promise<P>;
|
|
30
30
|
export declare const log$: <T extends unknown[], P>(fn: (...args: T) => PromiseLike<P>) => (...args: T) => PromiseLike<P>;
|
|
31
31
|
export declare const retry$: <T extends unknown[], P>(fn: (...args: T) => P | PromiseLike<P>, n: number) => (...args: T) => Promise<P>;
|
|
32
|
-
export declare const invoke$: <T, A extends unknown[]>(fn: T | ((...args: A) => T | PromiseLike<T>), ...args: A) => Promise<Awaited<T> | Awaited<T>>;
|
|
32
|
+
export declare const invoke$: <T, A extends unknown[]>(fn: T | ((...args: A) => T | PromiseLike<T>), ...args: A) => Promise<Awaited<T> | Awaited<T> | Awaited<T extends (...args: any[]) => infer R ? R : T>>;
|
|
33
33
|
export {};
|