@neovici/cosmoz-utils 6.10.1 → 6.12.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/memoize.d.ts +3 -4
- package/dist/object.d.ts +1 -1
- package/dist/promise.d.ts +1 -0
- package/dist/promise.js +14 -0
- package/package.json +1 -1
package/dist/memoize.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export function memoooize(fn: any): (arg1: any, arg2: any, arg3: any) => any;
|
|
1
|
+
type SameAs<T extends (...args: any) => any> = (...args: Parameters<T>) => ReturnType<T>;
|
|
2
|
+
export declare const memize: <T extends () => ReturnType<T>>(fn: T) => SameAs<T>, memoize: <T extends (arg: any) => ReturnType<T>>(fn: T) => SameAs<T>, memooize: <T extends (arg1: any, arg2: any) => ReturnType<T>>(fn: T) => SameAs<T>, memoooize: <T extends (arg1: any, arg2: any, arg3: any) => ReturnType<T>>(fn: T) => SameAs<T>;
|
|
3
|
+
export {};
|
package/dist/object.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function prop(a: '' | null | false | undefined | 0): typeof ident
|
|
|
5
5
|
export declare function prop<K extends PropertyKey>(key?: K): <O>(obj: O) => K extends keyof O ? O[K] : undefined;
|
|
6
6
|
export declare const strProp: <K extends PropertyKey>(key?: K | undefined) => <O>(o: O) => string;
|
|
7
7
|
export declare const transform: <K extends string, V, RK extends PropertyKey, RV>(obj: Record<K, V>, trans: (entries: [Extract<K, string>, V][]) => Iterable<readonly [RK, RV]>) => { [key in RK]: RV; };
|
|
8
|
-
export declare const omit: <K extends PropertyKey>(keys: K
|
|
8
|
+
export declare const omit: <const K extends readonly PropertyKey[]>(keys: K) => <const T extends Rec<PropertyKey, any>>(obj: T) => Omit<T, K[number]>;
|
|
9
9
|
export declare const props: <K extends PropertyKey>(keys: K[]) => <T extends Rec<PropertyKey, any>>(obj: T) => { [key in K & keyof T]: T[key]; };
|
|
10
10
|
type Merge<T1, T2> = {
|
|
11
11
|
[key in Exclude<keyof T1, keyof T2>]: T1[key];
|
package/dist/promise.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export declare const event$: <E extends Event, P extends Predicate<E> = Predicat
|
|
|
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 declare const log$: <T extends unknown[], P>(fn: (...args: T) => PromiseLike<P>) => (...args: T) => PromiseLike<P>;
|
|
12
|
+
export declare const retry$: <T extends unknown[], P>(fn: (...args: T) => P | PromiseLike<P>, n: number) => (...args: T) => Promise<P>;
|
|
12
13
|
export {};
|
package/dist/promise.js
CHANGED
|
@@ -70,3 +70,17 @@ export const log$ = (fn) => (...args) => fn(...args).then((response) => {
|
|
|
70
70
|
console.log(response);
|
|
71
71
|
return response;
|
|
72
72
|
});
|
|
73
|
+
export const retry$ = (fn, n) => async (...args) => {
|
|
74
|
+
let r = 0;
|
|
75
|
+
let error;
|
|
76
|
+
while (r < n) {
|
|
77
|
+
try {
|
|
78
|
+
return await fn(...args);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
error = e;
|
|
82
|
+
r++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
};
|