@neovici/cosmoz-utils 5.24.0 → 5.24.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 +2 -1
- package/dist/function.js +2 -1
- package/package.json +1 -1
package/dist/function.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type OrFn<T> = (...args: T[]) => boolean;
|
|
2
2
|
type OnceFn<A, R> = (...args: A[]) => R;
|
|
3
3
|
type OnceCheckFn<T> = (args: T[]) => boolean | undefined;
|
|
4
|
-
export declare const constant: <T>(v?: T | undefined) => () => T | undefined, constTrue: () => boolean | undefined, constUndefined: () => unknown, noop: () => unknown, identity: <T>(obj: T) => T, or: <A, F extends OrFn<A>>(...fns: F[]) => (...args: A[]) => boolean
|
|
4
|
+
export declare const constant: <T>(v?: T | undefined) => () => T | undefined, constTrue: () => boolean | undefined, constUndefined: () => unknown, noop: () => unknown, identity: <T>(obj: T) => T, or: <A, F extends OrFn<A>>(...fns: F[]) => (...args: A[]) => boolean;
|
|
5
|
+
export declare const once: <A, R>(fn: OnceFn<A, R>, check?: OnceCheckFn<A>) => (...args: A[]) => any;
|
|
5
6
|
export declare function invoke<A, R, F extends (...args: A[]) => R>(fn: F, ...args: A[]): ReturnType<F>;
|
|
6
7
|
export declare function invoke<F>(fn: F, ...args: unknown[]): F;
|
|
7
8
|
export {};
|
package/dist/function.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export const constant = (v) => () => v, constTrue = constant(true), constUndefined = constant(), noop = constUndefined, identity = (obj) => obj, or = (...fns) => (...args) => fns.reduce((res, fn) => res || fn(...args), false)
|
|
1
|
+
export const constant = (v) => () => v, constTrue = constant(true), constUndefined = constant(), noop = constUndefined, identity = (obj) => obj, or = (...fns) => (...args) => fns.reduce((res, fn) => res || fn(...args), false);
|
|
2
|
+
export const once = (fn, check = constTrue) => {
|
|
2
3
|
let result;
|
|
3
4
|
return (...args) => (result ??= check(args) ? fn(...args) : undefined);
|
|
4
5
|
};
|