@neovici/cosmoz-utils 6.1.0 → 6.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/function.d.ts +3 -1
- package/dist/function.js +4 -1
- package/dist/promise.d.ts +1 -1
- package/package.json +1 -1
package/dist/function.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ type OrFn<T> = (...args: T[]) => boolean;
|
|
|
2
2
|
type Arr = any[];
|
|
3
3
|
type OnceFn<A extends Arr, R> = (...args: A) => R;
|
|
4
4
|
type OnceCheckFn<A extends Arr> = (args: A) => boolean | undefined;
|
|
5
|
-
export declare
|
|
5
|
+
export declare function constant(): () => undefined;
|
|
6
|
+
export declare function constant<T>(v: T): () => T;
|
|
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;
|
|
6
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;
|
|
7
9
|
export declare function invoke<A, R, F extends (...args: A[]) => R>(fn: F, ...args: A[]): ReturnType<F>;
|
|
8
10
|
export declare function invoke<F>(fn: F, ...args: unknown[]): F;
|
package/dist/function.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function constant(v) {
|
|
2
|
+
return () => v;
|
|
3
|
+
}
|
|
4
|
+
export const constTrue = constant(true), constUndefined = constant(), noop = constUndefined, identity = (obj) => obj, or = (...fns) => (...args) => fns.reduce((res, fn) => res || fn(...args), false);
|
|
2
5
|
export const once = (fn, check = constTrue) => {
|
|
3
6
|
let result;
|
|
4
7
|
return (...args) => (result ??= check(args) ? fn(...args) : undefined);
|
package/dist/promise.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class ManagedPromise<T> extends Promise<T> {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const timeout$: (ms?: number) => Promise<unknown>;
|
|
7
7
|
type Predicate<T extends Event> = (e: T) => boolean;
|
|
8
|
-
export declare const event$: <E extends Event, P extends Predicate<E>>(target: EventTarget, type: string, predicate?: P | undefined, timeout?: number) => Promise<
|
|
8
|
+
export declare const event$: <E extends Event, P extends Predicate<E> = Predicate<E>>(target: EventTarget, type: string, predicate?: P | undefined, timeout?: number) => Promise<E>;
|
|
9
9
|
export declare const limit$: <T extends unknown[], P>(fn: (...args: T) => PromiseLike<P>, limit: number) => (...args: T) => Promise<P>;
|
|
10
10
|
export declare const debounce$: <T extends unknown[], P>(fn: (...args: T) => P | PromiseLike<P>, ms?: number) => (...args: T) => Promise<P>;
|
|
11
11
|
export {};
|