@inrixia/helpers 3.0.0 → 3.2.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/conv.d.ts +27 -27
- package/dist/conv.d.ts.map +1 -1
- package/dist/conv.js +41 -41
- package/dist/fn/Promize.d.ts +15 -15
- package/dist/fn/Promize.js +24 -24
- package/dist/fn/Semaphore.d.ts +6 -6
- package/dist/fn/Semaphore.js +30 -30
- package/dist/fn/Semaphore.js.map +1 -1
- package/dist/fn/asyncDebounce.d.ts +1 -1
- package/dist/fn/asyncDebounce.d.ts.map +1 -1
- package/dist/fn/asyncDebounce.js +25 -25
- package/dist/fn/asyncDebounce.js.map +1 -1
- package/dist/fn/debounce.d.ts +1 -1
- package/dist/fn/debounce.d.ts.map +1 -1
- package/dist/fn/debounce.js +12 -12
- package/dist/fn/loopError.d.ts +10 -10
- package/dist/fn/loopError.d.ts.map +1 -1
- package/dist/fn/loopError.js +13 -13
- package/dist/fn/memoize.d.ts +3 -1
- package/dist/fn/memoize.d.ts.map +1 -1
- package/dist/fn/memoize.js +14 -17
- package/dist/fn/memoize.js.map +1 -1
- package/dist/fn/retry.d.ts +6 -7
- package/dist/fn/retry.d.ts.map +1 -1
- package/dist/fn/retry.js +25 -25
- package/dist/fn/retry.js.map +1 -1
- package/dist/fn/runFor.d.ts +1 -1
- package/dist/fn/runFor.d.ts.map +1 -1
- package/dist/fn/runFor.js +10 -10
- package/dist/fn/runFor.js.map +1 -1
- package/dist/fn/toBase64Image.d.ts +1 -1
- package/dist/fn/toBase64Image.d.ts.map +1 -1
- package/dist/fn/toBase64Image.js +13 -13
- package/dist/fn/toRange.d.ts +8 -8
- package/dist/fn/toRange.d.ts.map +1 -1
- package/dist/fn/toRange.js +25 -25
- package/dist/fn/toRange.js.map +1 -1
- package/dist/fs/exists.d.ts +1 -1
- package/dist/fs/exists.d.ts.map +1 -1
- package/dist/fs/exists.js +11 -11
- package/dist/fs/exists.js.map +1 -1
- package/dist/geo.d.ts +18 -18
- package/dist/geo.d.ts.map +1 -1
- package/dist/geo.js +31 -31
- package/dist/index.d.ts +36 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/math/angleDifference.d.ts +8 -8
- package/dist/math/angleDifference.d.ts.map +1 -1
- package/dist/math/angleDifference.js +15 -15
- package/dist/math/nPad.d.ts +13 -13
- package/dist/math/nPad.d.ts.map +1 -1
- package/dist/math/nPad.js +18 -18
- package/dist/math/qRnd.d.ts +7 -7
- package/dist/math/qRnd.d.ts.map +1 -1
- package/dist/math/qRnd.js +10 -10
- package/dist/math/to360.d.ts +6 -6
- package/dist/math/to360.d.ts.map +1 -1
- package/dist/math/to360.js +9 -9
- package/dist/obj/RecursiveUpdateOptions.d.ts +14 -14
- package/dist/obj/RecursiveUpdateOptions.d.ts.map +1 -1
- package/dist/obj/RecursiveUpdateOptions.js +22 -22
- package/dist/obj/RecursiveUpdateOptions.js.map +1 -1
- package/dist/obj/chunkArray.d.ts +8 -8
- package/dist/obj/chunkArray.d.ts.map +1 -1
- package/dist/obj/chunkArray.js +16 -16
- package/dist/obj/compare.d.ts +23 -23
- package/dist/obj/compare.d.ts.map +1 -1
- package/dist/obj/compare.js +58 -58
- package/dist/obj/compare.js.map +1 -1
- package/dist/obj/deepGet.d.ts +16 -16
- package/dist/obj/deepGet.d.ts.map +1 -1
- package/dist/obj/deepGet.js +20 -20
- package/dist/obj/deepMerge.d.ts +7 -7
- package/dist/obj/deepMerge.d.ts.map +1 -1
- package/dist/obj/deepMerge.js +22 -22
- package/dist/obj/deepMerge.js.map +1 -1
- package/dist/obj/envOrThrow.d.ts +4 -4
- package/dist/obj/envOrThrow.d.ts.map +1 -1
- package/dist/obj/envOrThrow.js +9 -9
- package/dist/obj/fillTemplate.d.ts +17 -17
- package/dist/obj/fillTemplate.d.ts.map +1 -1
- package/dist/obj/fillTemplate.js +26 -26
- package/dist/obj/fillTemplate.js.map +1 -1
- package/dist/obj/getEnv.d.ts +10 -10
- package/dist/obj/getEnv.js +42 -42
- package/dist/obj/getEnv.js.map +1 -1
- package/dist/obj/hash.d.ts +1 -1
- package/dist/obj/hash.d.ts.map +1 -1
- package/dist/obj/hash.js +11 -11
- package/dist/obj/inspect.d.ts +25 -25
- package/dist/obj/inspect.d.ts.map +1 -1
- package/dist/obj/inspect.js +35 -35
- package/dist/obj/objectify.d.ts +14 -14
- package/dist/obj/objectify.d.ts.map +1 -1
- package/dist/obj/objectify.js +13 -13
- package/dist/obj/rebuildTypes.d.ts +5 -5
- package/dist/obj/rebuildTypes.d.ts.map +1 -1
- package/dist/obj/rebuildTypes.js +23 -23
- package/dist/obj/rebuildTypes.js.map +1 -1
- package/dist/test.d.ts +26 -26
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +68 -68
- package/dist/test.js.map +1 -1
- package/dist/ts/isKeyOf.d.ts +5 -5
- package/dist/ts/isKeyOf.d.ts.map +1 -1
- package/dist/ts/isKeyOf.js +4 -4
- package/dist/ts/isTypeOf.d.ts +11 -11
- package/dist/ts/isTypeOf.d.ts.map +1 -1
- package/dist/ts/isTypeOf.js +11 -11
- package/dist/ts/math.d.ts +11 -11
- package/dist/ts/math.js +1 -1
- package/dist/ts/numRange.d.ts +11 -11
- package/dist/ts/numRange.js +1 -1
- package/dist/ts/typeOf.d.ts +23 -23
- package/dist/ts/typeOf.d.ts.map +1 -1
- package/dist/ts/typeOf.js +27 -27
- package/dist/ts/typeOf.js.map +1 -1
- package/dist/ts/types.d.ts +30 -30
- package/dist/ts/types.js +1 -1
- package/package.json +5 -29
- package/dist/fn/index.d.ts +0 -11
- package/dist/fn/index.d.ts.map +0 -1
- package/dist/fn/index.js +0 -11
- package/dist/fn/index.js.map +0 -1
- package/dist/fs/index.d.ts +0 -2
- package/dist/fs/index.d.ts.map +0 -1
- package/dist/fs/index.js +0 -2
- package/dist/fs/index.js.map +0 -1
- package/dist/math/index.d.ts +0 -5
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -5
- package/dist/math/index.js.map +0 -1
- package/dist/obj/index.d.ts +0 -13
- package/dist/obj/index.d.ts.map +0 -1
- package/dist/obj/index.js +0 -13
- package/dist/obj/index.js.map +0 -1
- package/dist/ts/index.d.ts +0 -7
- package/dist/ts/index.d.ts.map +0 -1
- package/dist/ts/index.js +0 -7
- package/dist/ts/index.js.map +0 -1
package/dist/conv.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
3
|
-
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
4
|
-
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
5
|
-
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
6
|
-
*
|
|
7
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
8
|
-
*/
|
|
9
|
-
export declare const dryBulbTemp: (dewPointTemp: number, relativeHumidity: number) => number;
|
|
10
|
-
/**
|
|
11
|
-
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
12
|
-
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
13
|
-
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
14
|
-
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
15
|
-
*
|
|
16
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
17
|
-
*/
|
|
18
|
-
export declare const dewPointTemp: (dryBulbTemp: number, relativeHumidity: number) => number;
|
|
19
|
-
/**
|
|
20
|
-
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
21
|
-
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
22
|
-
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
23
|
-
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
24
|
-
*
|
|
25
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
26
|
-
*/
|
|
27
|
-
export declare const relativeHumidity: (dryBulbTemp: number, dewPointTemp: number) => number;
|
|
1
|
+
/**
|
|
2
|
+
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
3
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
4
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
5
|
+
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
6
|
+
*
|
|
7
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
8
|
+
*/
|
|
9
|
+
export declare const dryBulbTemp: (dewPointTemp: number, relativeHumidity: number) => number;
|
|
10
|
+
/**
|
|
11
|
+
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
12
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
13
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
14
|
+
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
15
|
+
*
|
|
16
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
17
|
+
*/
|
|
18
|
+
export declare const dewPointTemp: (dryBulbTemp: number, relativeHumidity: number) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
21
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
22
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
23
|
+
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
24
|
+
*
|
|
25
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
26
|
+
*/
|
|
27
|
+
export declare const relativeHumidity: (dryBulbTemp: number, dewPointTemp: number) => number;
|
|
28
28
|
//# sourceMappingURL=conv.d.ts.map
|
package/dist/conv.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conv.d.ts","sourceRoot":"","sources":["../src/conv.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"conv.d.ts","sourceRoot":"","sources":["../src/conv.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,cAAc,MAAM,EAAE,kBAAkB,MAAM,KAAG,MAI5E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,aAAa,MAAM,EAAE,kBAAkB,MAAM,KAAG,MAI5E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,EAAE,cAAc,MAAM,KAAG,MAI5E,CAAC"}
|
package/dist/conv.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const a = 17.625;
|
|
2
|
-
const b = 243.04;
|
|
3
|
-
/**
|
|
4
|
-
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
5
|
-
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
6
|
-
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
7
|
-
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
8
|
-
*
|
|
9
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
10
|
-
*/
|
|
11
|
-
export const dryBulbTemp = (dewPointTemp, relativeHumidity) => {
|
|
12
|
-
const lnRH = Math.log(relativeHumidity / 100);
|
|
13
|
-
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
14
|
-
return (b * (aTdbTd - lnRH)) / (a + lnRH - aTdbTd);
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
18
|
-
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
19
|
-
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
20
|
-
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
21
|
-
*
|
|
22
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
23
|
-
*/
|
|
24
|
-
export const dewPointTemp = (dryBulbTemp, relativeHumidity) => {
|
|
25
|
-
const lnRH = Math.log(relativeHumidity / 100);
|
|
26
|
-
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
27
|
-
return (b * (lnRH + aTbT)) / (a - lnRH - aTbT);
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
31
|
-
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
32
|
-
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
33
|
-
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
34
|
-
*
|
|
35
|
-
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
36
|
-
*/
|
|
37
|
-
export const relativeHumidity = (dryBulbTemp, dewPointTemp) => {
|
|
38
|
-
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
39
|
-
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
40
|
-
return 100 * (Math.exp(aTdbTd) / Math.exp(aTbT));
|
|
41
|
-
};
|
|
1
|
+
const a = 17.625;
|
|
2
|
+
const b = 243.04;
|
|
3
|
+
/**
|
|
4
|
+
* Get `dryBulbTemp` from `dewBulbTemp` and `relativeHumidity`
|
|
5
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
6
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
7
|
+
* @returns `dryBulbTemp` - Dry bulb temperature in degrees celsius
|
|
8
|
+
*
|
|
9
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
10
|
+
*/
|
|
11
|
+
export const dryBulbTemp = (dewPointTemp, relativeHumidity) => {
|
|
12
|
+
const lnRH = Math.log(relativeHumidity / 100);
|
|
13
|
+
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
14
|
+
return (b * (aTdbTd - lnRH)) / (a + lnRH - aTdbTd);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get `dewPointTemp` from `dryBulbTemp` and `relativeHumidity`
|
|
18
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
19
|
+
* @param relativeHumidity Relative humidity in whole number percent 0-100
|
|
20
|
+
* @returns `dewPointTemp` - Dew point temperature in degrees celsius
|
|
21
|
+
*
|
|
22
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
23
|
+
*/
|
|
24
|
+
export const dewPointTemp = (dryBulbTemp, relativeHumidity) => {
|
|
25
|
+
const lnRH = Math.log(relativeHumidity / 100);
|
|
26
|
+
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
27
|
+
return (b * (lnRH + aTbT)) / (a - lnRH - aTbT);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get `relativeHumidity` from `dryBulbTemp` and `dewPointTemp`
|
|
31
|
+
* @param dryBulbTemp Dry bulb temperature in degrees celsius
|
|
32
|
+
* @param dewPointTemp Dew point temperature in degrees celsius
|
|
33
|
+
* @returns `dryBulbTemp` - Relative humidity in whole number percent 0-100
|
|
34
|
+
*
|
|
35
|
+
* @url https://bmcnoldy.rsmas.miami.edu/humidity_conversions.pdf
|
|
36
|
+
*/
|
|
37
|
+
export const relativeHumidity = (dryBulbTemp, dewPointTemp) => {
|
|
38
|
+
const aTdbTd = (a * dewPointTemp) / (b + dewPointTemp);
|
|
39
|
+
const aTbT = (a * dryBulbTemp) / (b + dryBulbTemp);
|
|
40
|
+
return 100 * (Math.exp(aTdbTd) / Math.exp(aTbT));
|
|
41
|
+
};
|
|
42
42
|
//# sourceMappingURL=conv.js.map
|
package/dist/fn/Promize.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare class Promize<T> {
|
|
2
|
-
p: Promise<T>;
|
|
3
|
-
res: (value: T) => void;
|
|
4
|
-
rej: (reason?: any) => void;
|
|
5
|
-
/**
|
|
6
|
-
* Returns a new instance of a `Promize`, a externally resolvable Promise.
|
|
7
|
-
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
8
|
-
*/
|
|
9
|
-
constructor(resValue?: T);
|
|
10
|
-
/**
|
|
11
|
-
* Recreate the promise
|
|
12
|
-
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
13
|
-
*/
|
|
14
|
-
set(resValue?: T): void;
|
|
15
|
-
}
|
|
1
|
+
export declare class Promize<T> {
|
|
2
|
+
p: Promise<T>;
|
|
3
|
+
res: (value: T) => void;
|
|
4
|
+
rej: (reason?: any) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a new instance of a `Promize`, a externally resolvable Promise.
|
|
7
|
+
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
8
|
+
*/
|
|
9
|
+
constructor(resValue?: T);
|
|
10
|
+
/**
|
|
11
|
+
* Recreate the promise
|
|
12
|
+
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
13
|
+
*/
|
|
14
|
+
set(resValue?: T): void;
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=Promize.d.ts.map
|
package/dist/fn/Promize.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export class Promize {
|
|
2
|
-
p;
|
|
3
|
-
res;
|
|
4
|
-
rej;
|
|
5
|
-
/**
|
|
6
|
-
* Returns a new instance of a `Promize`, a externally resolvable Promise.
|
|
7
|
-
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
8
|
-
*/
|
|
9
|
-
constructor(resValue) {
|
|
10
|
-
this.set(resValue);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Recreate the promise
|
|
14
|
-
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
15
|
-
*/
|
|
16
|
-
set(resValue) {
|
|
17
|
-
this.p = new Promise((res, rej) => {
|
|
18
|
-
this.res = res;
|
|
19
|
-
this.rej = rej;
|
|
20
|
-
});
|
|
21
|
-
if (resValue !== undefined)
|
|
22
|
-
this.res(resValue);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
export class Promize {
|
|
2
|
+
p;
|
|
3
|
+
res;
|
|
4
|
+
rej;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a new instance of a `Promize`, a externally resolvable Promise.
|
|
7
|
+
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
8
|
+
*/
|
|
9
|
+
constructor(resValue) {
|
|
10
|
+
this.set(resValue);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Recreate the promise
|
|
14
|
+
* @param resValue If not undefined, resolves the internal promise with given value on creation.
|
|
15
|
+
*/
|
|
16
|
+
set(resValue) {
|
|
17
|
+
this.p = new Promise((res, rej) => {
|
|
18
|
+
this.res = res;
|
|
19
|
+
this.rej = rej;
|
|
20
|
+
});
|
|
21
|
+
if (resValue !== undefined)
|
|
22
|
+
this.res(resValue);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
25
|
//# sourceMappingURL=Promize.js.map
|
package/dist/fn/Semaphore.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare class Semaphore {
|
|
2
|
-
private avalibleSlots;
|
|
3
|
-
private readonly _queue;
|
|
4
|
-
constructor(avalibleSlots: number);
|
|
5
|
-
obtain(): Promise<() => void>;
|
|
6
|
-
}
|
|
1
|
+
export declare class Semaphore {
|
|
2
|
+
private avalibleSlots;
|
|
3
|
+
private readonly _queue;
|
|
4
|
+
constructor(avalibleSlots: number);
|
|
5
|
+
obtain(): Promise<() => void>;
|
|
6
|
+
}
|
|
7
7
|
//# sourceMappingURL=Semaphore.d.ts.map
|
package/dist/fn/Semaphore.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export class Semaphore {
|
|
2
|
-
avalibleSlots;
|
|
3
|
-
_queue = [];
|
|
4
|
-
constructor(avalibleSlots) {
|
|
5
|
-
this.avalibleSlots = avalibleSlots;
|
|
6
|
-
}
|
|
7
|
-
async obtain() {
|
|
8
|
-
let released = false;
|
|
9
|
-
const release = () => {
|
|
10
|
-
if (released)
|
|
11
|
-
return;
|
|
12
|
-
released = true;
|
|
13
|
-
this.avalibleSlots++;
|
|
14
|
-
// If there are queued requests, resolve the first one in the queue
|
|
15
|
-
this._queue.shift()?.();
|
|
16
|
-
};
|
|
17
|
-
// If there is an available request slot, proceed immediately
|
|
18
|
-
if (this.avalibleSlots > 0) {
|
|
19
|
-
this.avalibleSlots--;
|
|
20
|
-
return release;
|
|
21
|
-
}
|
|
22
|
-
// Otherwise, wait for a request slot to become available
|
|
23
|
-
return new Promise((r) => {
|
|
24
|
-
this._queue.push(() => {
|
|
25
|
-
this.avalibleSlots--;
|
|
26
|
-
r(release);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
export class Semaphore {
|
|
2
|
+
avalibleSlots;
|
|
3
|
+
_queue = [];
|
|
4
|
+
constructor(avalibleSlots) {
|
|
5
|
+
this.avalibleSlots = avalibleSlots;
|
|
6
|
+
}
|
|
7
|
+
async obtain() {
|
|
8
|
+
let released = false;
|
|
9
|
+
const release = () => {
|
|
10
|
+
if (released)
|
|
11
|
+
return;
|
|
12
|
+
released = true;
|
|
13
|
+
this.avalibleSlots++;
|
|
14
|
+
// If there are queued requests, resolve the first one in the queue
|
|
15
|
+
this._queue.shift()?.();
|
|
16
|
+
};
|
|
17
|
+
// If there is an available request slot, proceed immediately
|
|
18
|
+
if (this.avalibleSlots > 0) {
|
|
19
|
+
this.avalibleSlots--;
|
|
20
|
+
return release;
|
|
21
|
+
}
|
|
22
|
+
// Otherwise, wait for a request slot to become available
|
|
23
|
+
return new Promise((r) => {
|
|
24
|
+
this._queue.push(() => {
|
|
25
|
+
this.avalibleSlots--;
|
|
26
|
+
r(release);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
31
|
//# sourceMappingURL=Semaphore.js.map
|
package/dist/fn/Semaphore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Semaphore.js","sourceRoot":"","sources":["../../src/fn/Semaphore.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IAED;IADH,MAAM,GAAmB,EAAE,CAAC;IAC7C,YAAoB,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,MAAM;QAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,mEAAmE;YACnE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,6DAA6D;QAC7D,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"Semaphore.js","sourceRoot":"","sources":["../../src/fn/Semaphore.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IAED;IADH,MAAM,GAAmB,EAAE,CAAC;IAC7C,YAAoB,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,MAAM;QAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,mEAAmE;YACnE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,6DAA6D;QAC7D,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC;QAChB,CAAC;QAED,yDAAyD;QACzD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;gBACrB,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,CAAC,CAAC,OAAO,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const asyncDebounce: <A extends any[], V>(generator: (...args: A) => Promise<V>) => (...args: A) => Promise<V>;
|
|
1
|
+
export declare const asyncDebounce: <A extends any[], V>(generator: (...args: A) => Promise<V>) => (...args: A) => Promise<V>;
|
|
2
2
|
//# sourceMappingURL=asyncDebounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncDebounce.d.ts","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"asyncDebounce.d.ts","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,EAAE,WAAW,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,eAY7D,CAAC,KAAG,OAAO,CAAC,CAAC,CAStC,CAAC"}
|
package/dist/fn/asyncDebounce.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export const asyncDebounce = (generator) => {
|
|
2
|
-
if (generator.length === 0) {
|
|
3
|
-
let _current;
|
|
4
|
-
const _func = () => {
|
|
5
|
-
if (_current)
|
|
6
|
-
return _current;
|
|
7
|
-
_current = generator();
|
|
8
|
-
_current.finally(() => (_current = undefined));
|
|
9
|
-
return _current;
|
|
10
|
-
};
|
|
11
|
-
return _func;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
const _current = {};
|
|
15
|
-
const _func = (...args) => {
|
|
16
|
-
const key = JSON.stringify(args);
|
|
17
|
-
if (key in _current)
|
|
18
|
-
return _current[key];
|
|
19
|
-
_current[key] = generator(...args);
|
|
20
|
-
_current[key].finally(() => delete _current[key]);
|
|
21
|
-
return _current[key];
|
|
22
|
-
};
|
|
23
|
-
return _func;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
1
|
+
export const asyncDebounce = (generator) => {
|
|
2
|
+
if (generator.length === 0) {
|
|
3
|
+
let _current;
|
|
4
|
+
const _func = () => {
|
|
5
|
+
if (_current)
|
|
6
|
+
return _current;
|
|
7
|
+
_current = generator();
|
|
8
|
+
_current.finally(() => (_current = undefined));
|
|
9
|
+
return _current;
|
|
10
|
+
};
|
|
11
|
+
return _func;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const _current = {};
|
|
15
|
+
const _func = (...args) => {
|
|
16
|
+
const key = JSON.stringify(args);
|
|
17
|
+
if (key in _current)
|
|
18
|
+
return _current[key];
|
|
19
|
+
_current[key] = generator(...args);
|
|
20
|
+
_current[key].finally(() => delete _current[key]);
|
|
21
|
+
return _current[key];
|
|
22
|
+
};
|
|
23
|
+
return _func;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
26
|
//# sourceMappingURL=asyncDebounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncDebounce.js","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAqB,SAAqC,EAAE,EAAE;IAC1F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"asyncDebounce.js","sourceRoot":"","sources":["../../src/fn/asyncDebounce.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAqB,SAAqC,EAAE,EAAE;IAC1F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,IAAI,QAAgC,CAAC;QACrC,MAAM,KAAK,GAAG,GAAe,EAAE;YAC9B,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YAC9B,QAAQ,GAAI,SAA8B,EAAE,CAAC;YAC7C,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC;YAC/C,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,CAAC;QACP,MAAM,QAAQ,GAA+B,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAO,EAAc,EAAE;YACxC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,GAAG,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1C,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;YACnC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC,CAAC"}
|
package/dist/fn/debounce.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => (...args: Parameters<T>) => void;
|
|
1
|
+
export declare const debounce: <T extends (...args: any[]) => any>(func: T, wait: number) => ((...args: Parameters<T>) => void);
|
|
2
2
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/fn/debounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/fn/debounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,MAAM,KAAG,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAUpH,CAAC"}
|
package/dist/fn/debounce.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export const debounce = (func, wait) => {
|
|
2
|
-
let timeout;
|
|
3
|
-
return async function (...args) {
|
|
4
|
-
const context = this;
|
|
5
|
-
if (timeout)
|
|
6
|
-
clearTimeout(timeout);
|
|
7
|
-
timeout = setTimeout(async () => {
|
|
8
|
-
timeout = null;
|
|
9
|
-
func.apply(context, args);
|
|
10
|
-
}, wait);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
1
|
+
export const debounce = (func, wait) => {
|
|
2
|
+
let timeout;
|
|
3
|
+
return async function (...args) {
|
|
4
|
+
const context = this;
|
|
5
|
+
if (timeout)
|
|
6
|
+
clearTimeout(timeout);
|
|
7
|
+
timeout = setTimeout(async () => {
|
|
8
|
+
timeout = null;
|
|
9
|
+
func.apply(context, args);
|
|
10
|
+
}, wait);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
13
|
//# sourceMappingURL=debounce.js.map
|
package/dist/fn/loopError.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AsyncFunction } from "../ts/types.js";
|
|
2
|
-
type ErrorHandler = (err: Error) => Promise<void>;
|
|
3
|
-
/**
|
|
4
|
-
* Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
|
|
5
|
-
* @param func Function to execute
|
|
6
|
-
* @param errorHandler Function to execute when a error occours
|
|
7
|
-
* @returns Return value of `func` on success
|
|
8
|
-
*/
|
|
9
|
-
export declare const loopError: <F extends AsyncFunction>(func: F, errorHandler?: ErrorHandler) => ReturnType<F>;
|
|
10
|
-
export {};
|
|
1
|
+
import { AsyncFunction } from "../ts/types.js";
|
|
2
|
+
type ErrorHandler = (err: Error) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
|
|
5
|
+
* @param func Function to execute
|
|
6
|
+
* @param errorHandler Function to execute when a error occours
|
|
7
|
+
* @returns Return value of `func` on success
|
|
8
|
+
*/
|
|
9
|
+
export declare const loopError: <F extends AsyncFunction>(func: F, errorHandler?: ErrorHandler) => ReturnType<F>;
|
|
10
|
+
export {};
|
|
11
11
|
//# sourceMappingURL=loopError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopError.d.ts","sourceRoot":"","sources":["../../src/fn/loopError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD;;;;;GAKG;AAEH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"loopError.d.ts","sourceRoot":"","sources":["../../src/fn/loopError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAClD;;;;;GAKG;AAEH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,aAAa,EAAE,MAAM,CAAC,EAAE,eAAc,YAA+D,KAAG,UAAU,CAAC,CAAC,CAOpI,CAAC"}
|
package/dist/fn/loopError.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
|
|
3
|
-
* @param func Function to execute
|
|
4
|
-
* @param errorHandler Function to execute when a error occours
|
|
5
|
-
* @returns Return value of `func` on success
|
|
6
|
-
*/
|
|
7
|
-
export const loopError = (func, errorHandler = (err) => new Promise((_res, r) => r(err))) => new Promise((resolve) => {
|
|
8
|
-
func()
|
|
9
|
-
.then(resolve)
|
|
10
|
-
.catch(async (err) => {
|
|
11
|
-
errorHandler(err).then(() => resolve(loopError(func, errorHandler)));
|
|
12
|
-
});
|
|
13
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Recursively runs `func` and handles errors with `errorHandler` until `func` successfully finishes.
|
|
3
|
+
* @param func Function to execute
|
|
4
|
+
* @param errorHandler Function to execute when a error occours
|
|
5
|
+
* @returns Return value of `func` on success
|
|
6
|
+
*/
|
|
7
|
+
export const loopError = (func, errorHandler = (err) => new Promise((_res, r) => r(err))) => new Promise((resolve) => {
|
|
8
|
+
func()
|
|
9
|
+
.then(resolve)
|
|
10
|
+
.catch(async (err) => {
|
|
11
|
+
errorHandler(err).then(() => resolve(loopError(func, errorHandler)));
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
14
|
//# sourceMappingURL=loopError.js.map
|
package/dist/fn/memoize.d.ts
CHANGED
package/dist/fn/memoize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG;IAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAAE,EAAE,WAAW,CAAC,KAAG,CAapI,CAAC"}
|
package/dist/fn/memoize.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
export const memoize = (generator) => {
|
|
2
|
-
if (generator.length === 0) {
|
|
3
|
-
let cache;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return (cache[key] ??= generator(...args));
|
|
16
|
-
});
|
|
17
|
-
};
|
|
1
|
+
export const memoize = (generator) => {
|
|
2
|
+
if (generator.length === 0) {
|
|
3
|
+
let cache;
|
|
4
|
+
const _fn = (() => (cache ??= generator()));
|
|
5
|
+
_fn.clear = () => (cache = undefined);
|
|
6
|
+
return _fn;
|
|
7
|
+
}
|
|
8
|
+
const cache = {};
|
|
9
|
+
const _fn = ((...args) => (cache[JSON.stringify(args)] ??= generator(...args)));
|
|
10
|
+
_fn.clear = (...args) => {
|
|
11
|
+
delete cache[JSON.stringify(args)];
|
|
12
|
+
};
|
|
13
|
+
return _fn;
|
|
14
|
+
};
|
|
18
15
|
//# sourceMappingURL=memoize.js.map
|
package/dist/fn/memoize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/fn/memoize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAA+F,SAAY,EAAK,EAAE;IACxI,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,IAAI,KAAc,CAAC;QACnB,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC,CAAiB,CAAC;QAC5D,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;QACtC,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAiB,CAAC;IAC3G,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;QAClC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC"}
|
package/dist/fn/retry.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} | undefined) => () => Promise<T>;
|
|
1
|
+
export declare const sleep: typeof import("timers/promises").setTimeout;
|
|
2
|
+
export declare const retry: <T>(func: () => Promise<T> | T, options?: {
|
|
3
|
+
onErr?: (error: unknown, retryCount: number) => void;
|
|
4
|
+
timeoutMultiplier?: number;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
}) => (() => Promise<T>);
|
|
8
7
|
//# sourceMappingURL=retry.d.ts.map
|
package/dist/fn/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,KAAK,6CAAwB,CAAC;AAE3C,eAAO,MAAM,KAAK,GAAI,CAAC,EACtB,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC1B,UAAU;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,KACjH,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAmBnB,CAAC"}
|
package/dist/fn/retry.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { promisify } from "util";
|
|
2
|
-
export const sleep = promisify(setTimeout);
|
|
3
|
-
export const retry = (func, options) => {
|
|
4
|
-
let retryCount = 0;
|
|
5
|
-
const maxRetries = options?.maxRetries ?? 10;
|
|
6
|
-
const timeoutMultiplier = options?.timeoutMultiplier ?? 1000;
|
|
7
|
-
const onErr = options?.onErr;
|
|
8
|
-
const tryAgain = async () => {
|
|
9
|
-
try {
|
|
10
|
-
return await func();
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
if (onErr !== undefined)
|
|
14
|
-
onErr(e, retryCount);
|
|
15
|
-
if (retryCount < maxRetries) {
|
|
16
|
-
retryCount++;
|
|
17
|
-
if (timeoutMultiplier > 0)
|
|
18
|
-
await sleep(Math.random() * timeoutMultiplier);
|
|
19
|
-
return tryAgain();
|
|
20
|
-
}
|
|
21
|
-
throw e;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return tryAgain;
|
|
25
|
-
};
|
|
1
|
+
import { promisify } from "util";
|
|
2
|
+
export const sleep = promisify(setTimeout);
|
|
3
|
+
export const retry = (func, options) => {
|
|
4
|
+
let retryCount = 0;
|
|
5
|
+
const maxRetries = options?.maxRetries ?? 10;
|
|
6
|
+
const timeoutMultiplier = options?.timeoutMultiplier ?? 1000;
|
|
7
|
+
const onErr = options?.onErr;
|
|
8
|
+
const tryAgain = async () => {
|
|
9
|
+
try {
|
|
10
|
+
return await func();
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
if (onErr !== undefined)
|
|
14
|
+
onErr(e, retryCount);
|
|
15
|
+
if (retryCount < maxRetries) {
|
|
16
|
+
retryCount++;
|
|
17
|
+
if (timeoutMultiplier > 0)
|
|
18
|
+
await sleep(Math.random() * timeoutMultiplier);
|
|
19
|
+
return tryAgain();
|
|
20
|
+
}
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return tryAgain;
|
|
25
|
+
};
|
|
26
26
|
//# sourceMappingURL=retry.js.map
|
package/dist/fn/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,IAA0B,EAC1B,OAAmH,EAC9F,EAAE;IACvB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;IAC7C,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,IAAI,CAAC;IAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAC7B,MAAM,QAAQ,GAAG,KAAK,IAAgB,EAAE;QACvC,IAAI;
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/fn/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,KAAK,GAAG,CACpB,IAA0B,EAC1B,OAAmH,EAC9F,EAAE;IACvB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;IAC7C,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,IAAI,CAAC;IAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAC7B,MAAM,QAAQ,GAAG,KAAK,IAAgB,EAAE;QACvC,IAAI,CAAC;YACJ,OAAO,MAAM,IAAI,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,KAAK,KAAK,SAAS;gBAAE,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;YAC9C,IAAI,UAAU,GAAG,UAAU,EAAE,CAAC;gBAC7B,UAAU,EAAE,CAAC;gBACb,IAAI,iBAAiB,GAAG,CAAC;oBAAE,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CAAC;gBAC1E,OAAO,QAAQ,EAAE,CAAC;YACnB,CAAC;YACD,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC"}
|
package/dist/fn/runFor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const runFor: (fn: () => true | undefined, timeoutMs: number) => Promise<void>;
|
|
1
|
+
export declare const runFor: (fn: () => true | undefined, timeoutMs: number) => Promise<void>;
|
|
2
2
|
//# sourceMappingURL=runFor.d.ts.map
|
package/dist/fn/runFor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runFor.d.ts","sourceRoot":"","sources":["../../src/fn/runFor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"runFor.d.ts","sourceRoot":"","sources":["../../src/fn/runFor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,GAAU,IAAI,MAAM,IAAI,GAAG,SAAS,EAAE,WAAW,MAAM,kBAOzE,CAAC"}
|