@naturalcycles/js-lib 14.241.0 → 14.241.2
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/abort.js +1 -2
- package/dist/array/array.util.js +39 -40
- package/dist/array/range.js +3 -4
- package/dist/datetime/localDate.js +2 -2
- package/dist/datetime/localTime.js +2 -2
- package/dist/decorators/asyncMemo.decorator.js +2 -2
- package/dist/decorators/createPromiseDecorator.js +1 -2
- package/dist/decorators/debounce.decorator.js +2 -3
- package/dist/decorators/debounce.js +2 -3
- package/dist/decorators/decorator.util.js +3 -4
- package/dist/decorators/logMethod.decorator.js +1 -2
- package/dist/decorators/memo.decorator.js +2 -2
- package/dist/decorators/memoFn.js +1 -2
- package/dist/decorators/memoFnAsync.js +1 -2
- package/dist/decorators/retry.decorator.js +1 -2
- package/dist/decorators/timeout.decorator.js +1 -2
- package/dist/define.js +6 -7
- package/dist/enum.util.js +20 -21
- package/dist/env/buildInfo.js +1 -2
- package/dist/env.js +2 -3
- package/dist/error/assert.js +9 -10
- package/dist/error/error.util.js +11 -11
- package/dist/error/try.js +6 -7
- package/dist/error/tryCatch.js +2 -2
- package/dist/form.util.js +2 -3
- package/dist/http/fetcher.d.ts +3 -3
- package/dist/http/fetcher.js +5 -5
- package/dist/http/fetcher.model.d.ts +2 -2
- package/dist/http/fetcher.model.js +2 -2
- package/dist/is.util.js +7 -7
- package/dist/json-schema/from-data/generateJsonSchemaFromData.js +1 -2
- package/dist/json-schema/jsonSchema.util.js +1 -2
- package/dist/json-schema/jsonSchemaBuilder.d.ts +8 -9
- package/dist/log/commonLogger.js +5 -5
- package/dist/math/math.util.js +6 -7
- package/dist/number/createDeterministicRandom.js +1 -2
- package/dist/number/number.util.js +9 -10
- package/dist/object/deepEquals.js +3 -4
- package/dist/object/object.util.js +26 -27
- package/dist/object/sortObject.js +1 -2
- package/dist/object/sortObjectDeep.js +1 -2
- package/dist/polyfill.js +1 -2
- package/dist/promise/abortable.js +2 -2
- package/dist/promise/pDefer.js +1 -2
- package/dist/promise/pDelay.js +2 -3
- package/dist/promise/pFilter.js +1 -2
- package/dist/promise/pHang.js +1 -2
- package/dist/promise/pMap.js +1 -2
- package/dist/promise/pProps.js +1 -2
- package/dist/promise/pRetry.js +2 -3
- package/dist/promise/pState.js +1 -2
- package/dist/promise/pTimeout.js +2 -3
- package/dist/semver.js +2 -2
- package/dist/string/case.js +3 -4
- package/dist/string/escape.js +2 -3
- package/dist/string/hash.util.js +4 -5
- package/dist/string/json.util.js +3 -4
- package/dist/string/leven.js +1 -2
- package/dist/string/lodash/unicodeWords.js +1 -2
- package/dist/string/lodash/words.js +1 -2
- package/dist/string/pupa.js +2 -2
- package/dist/string/readingTime.js +1 -2
- package/dist/string/safeJsonStringify.js +1 -2
- package/dist/string/string.util.js +13 -14
- package/dist/string/stringify.js +2 -3
- package/dist/string/url.util.js +1 -2
- package/dist/time/time.util.js +3 -4
- package/dist/types.d.ts +0 -1
- package/dist/types.js +2 -2
- package/dist/unit/size.util.js +5 -6
- package/dist/web.d.ts +2 -2
- package/dist/web.js +2 -2
- package/dist/zod/zod.util.js +4 -4
- package/dist-esm/http/fetcher.js +3 -3
- package/dist-esm/http/fetcher.model.js +2 -2
- package/dist-esm/web.js +2 -2
- package/package.json +1 -1
- package/src/enum.util.ts +1 -1
- package/src/http/fetcher.model.ts +2 -2
- package/src/http/fetcher.ts +3 -3
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +1 -1
- package/src/web.ts +2 -2
package/dist/math/math.util.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._average = _average;
|
|
4
|
+
exports._averageOrNull = _averageOrNull;
|
|
5
|
+
exports._averageWeighted = _averageWeighted;
|
|
6
|
+
exports._percentile = _percentile;
|
|
7
|
+
exports._percentiles = _percentiles;
|
|
8
|
+
exports._median = _median;
|
|
4
9
|
const number_util_1 = require("../number/number.util");
|
|
5
10
|
/**
|
|
6
11
|
* @returns Average of the array of numbers
|
|
@@ -13,14 +18,12 @@ const number_util_1 = require("../number/number.util");
|
|
|
13
18
|
function _average(values) {
|
|
14
19
|
return values.reduce((a, b) => a + b) / values.length;
|
|
15
20
|
}
|
|
16
|
-
exports._average = _average;
|
|
17
21
|
/**
|
|
18
22
|
* Same as _average, but safely returns null if input array is empty or nullish.
|
|
19
23
|
*/
|
|
20
24
|
function _averageOrNull(values) {
|
|
21
25
|
return values?.length ? values.reduce((a, b) => a + b) / values.length : null;
|
|
22
26
|
}
|
|
23
|
-
exports._averageOrNull = _averageOrNull;
|
|
24
27
|
/**
|
|
25
28
|
* valuesArray and weightsArray length is expected to be the same.
|
|
26
29
|
*/
|
|
@@ -29,7 +32,6 @@ function _averageWeighted(values, weights) {
|
|
|
29
32
|
const denominator = weights.reduce((a, b) => a + b);
|
|
30
33
|
return numerator / denominator;
|
|
31
34
|
}
|
|
32
|
-
exports._averageWeighted = _averageWeighted;
|
|
33
35
|
/**
|
|
34
36
|
* @example
|
|
35
37
|
*
|
|
@@ -51,7 +53,6 @@ function _percentile(values, pc) {
|
|
|
51
53
|
const ceilPos = Math.ceil(pos);
|
|
52
54
|
return _averageWeighted([sorted[floorPos], sorted[ceilPos]], [1 - dec, dec]);
|
|
53
55
|
}
|
|
54
|
-
exports._percentile = _percentile;
|
|
55
56
|
/**
|
|
56
57
|
* A tiny bit more efficient function than calling _percentile individually.
|
|
57
58
|
*/
|
|
@@ -68,7 +69,6 @@ function _percentiles(values, pcs) {
|
|
|
68
69
|
}
|
|
69
70
|
return r;
|
|
70
71
|
}
|
|
71
|
-
exports._percentiles = _percentiles;
|
|
72
72
|
/**
|
|
73
73
|
* @example
|
|
74
74
|
*
|
|
@@ -81,4 +81,3 @@ exports._percentiles = _percentiles;
|
|
|
81
81
|
function _median(values) {
|
|
82
82
|
return _percentile(values, 50);
|
|
83
83
|
}
|
|
84
|
-
exports._median = _median;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable no-bitwise */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports._createDeterministicRandom =
|
|
4
|
+
exports._createDeterministicRandom = _createDeterministicRandom;
|
|
5
5
|
/**
|
|
6
6
|
* Returns a "deterministic Math.random() function"
|
|
7
7
|
*
|
|
@@ -20,4 +20,3 @@ function _createDeterministicRandom() {
|
|
|
20
20
|
return (seed & 0xfffffff) / 0x10000000;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports._createDeterministicRandom = _createDeterministicRandom;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._randomInt = _randomInt;
|
|
4
|
+
exports._randomArrayItem = _randomArrayItem;
|
|
5
|
+
exports._runLessOften = _runLessOften;
|
|
6
|
+
exports._isBetween = _isBetween;
|
|
7
|
+
exports._clamp = _clamp;
|
|
8
|
+
exports._sortNumbers = _sortNumbers;
|
|
9
|
+
exports._toFixed = _toFixed;
|
|
10
|
+
exports._toPrecision = _toPrecision;
|
|
11
|
+
exports._round = _round;
|
|
4
12
|
function _randomInt(minIncl, maxIncl) {
|
|
5
13
|
return Math.floor(Math.random() * (maxIncl - minIncl + 1) + minIncl);
|
|
6
14
|
}
|
|
7
|
-
exports._randomInt = _randomInt;
|
|
8
15
|
/**
|
|
9
16
|
* Returns random item from an array.
|
|
10
17
|
* Should be used on non-empty arrays! (otherwise will return undefined,
|
|
@@ -13,7 +20,6 @@ exports._randomInt = _randomInt;
|
|
|
13
20
|
function _randomArrayItem(array) {
|
|
14
21
|
return array[_randomInt(0, array.length - 1)];
|
|
15
22
|
}
|
|
16
|
-
exports._randomArrayItem = _randomArrayItem;
|
|
17
23
|
/**
|
|
18
24
|
* Convenience function to "throttle" some code - run it less often.
|
|
19
25
|
*
|
|
@@ -26,7 +32,6 @@ exports._randomArrayItem = _randomArrayItem;
|
|
|
26
32
|
function _runLessOften(percent) {
|
|
27
33
|
return Math.random() * 100 < percent;
|
|
28
34
|
}
|
|
29
|
-
exports._runLessOften = _runLessOften;
|
|
30
35
|
// todo: _.random to support floats
|
|
31
36
|
/**
|
|
32
37
|
* _isBetween(-10, 1, 5) // false
|
|
@@ -50,11 +55,9 @@ function _isBetween(x, min, max, incl = '[)') {
|
|
|
50
55
|
}
|
|
51
56
|
return x > min && x < max;
|
|
52
57
|
}
|
|
53
|
-
exports._isBetween = _isBetween;
|
|
54
58
|
function _clamp(x, minIncl, maxIncl) {
|
|
55
59
|
return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x;
|
|
56
60
|
}
|
|
57
|
-
exports._clamp = _clamp;
|
|
58
61
|
/**
|
|
59
62
|
* This function exists, because in JS you cannot just .sort() numbers,
|
|
60
63
|
* as .sort() function first maps everything to String.
|
|
@@ -68,7 +71,6 @@ function _sortNumbers(numbers, mutate = false, dir = 'asc') {
|
|
|
68
71
|
const mod = dir === 'desc' ? -1 : 1;
|
|
69
72
|
return (mutate ? numbers : [...numbers]).sort((a, b) => (a - b) * mod);
|
|
70
73
|
}
|
|
71
|
-
exports._sortNumbers = _sortNumbers;
|
|
72
74
|
/**
|
|
73
75
|
* Same as .toFixed(), but conveniently casts the output to Number.
|
|
74
76
|
*
|
|
@@ -83,7 +85,6 @@ exports._sortNumbers = _sortNumbers;
|
|
|
83
85
|
function _toFixed(n, fractionDigits) {
|
|
84
86
|
return Number(n.toFixed(fractionDigits));
|
|
85
87
|
}
|
|
86
|
-
exports._toFixed = _toFixed;
|
|
87
88
|
/**
|
|
88
89
|
* Same as .toPrecision(), but conveniently casts the output to Number.
|
|
89
90
|
*
|
|
@@ -98,7 +99,6 @@ exports._toFixed = _toFixed;
|
|
|
98
99
|
function _toPrecision(n, precision) {
|
|
99
100
|
return Number(n.toPrecision(precision));
|
|
100
101
|
}
|
|
101
|
-
exports._toPrecision = _toPrecision;
|
|
102
102
|
/**
|
|
103
103
|
* @example
|
|
104
104
|
*
|
|
@@ -117,4 +117,3 @@ function _round(n, precisionUnit) {
|
|
|
117
117
|
const v = Math.floor(n) + Math.round((n % 1) / precisionUnit) * precisionUnit;
|
|
118
118
|
return Number(v.toFixed(String(precisionUnit).length - 2)); // '0.
|
|
119
119
|
}
|
|
120
|
-
exports._round = _round;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Heavily inspired by https://github.com/epoberezkin/fast-deep-equal
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports._deepEquals = _deepEquals;
|
|
5
|
+
exports._deepJsonEquals = _deepJsonEquals;
|
|
6
|
+
exports._jsonEquals = _jsonEquals;
|
|
5
7
|
/**
|
|
6
8
|
Returns true if a and b are deeply equal.
|
|
7
9
|
|
|
@@ -91,7 +93,6 @@ function _deepEquals(a, b) {
|
|
|
91
93
|
}
|
|
92
94
|
return a === b;
|
|
93
95
|
}
|
|
94
|
-
exports._deepEquals = _deepEquals;
|
|
95
96
|
/**
|
|
96
97
|
Returns true if a and b are deeply equal.
|
|
97
98
|
|
|
@@ -156,7 +157,6 @@ function _deepJsonEquals(a, b) {
|
|
|
156
157
|
}
|
|
157
158
|
return a === b;
|
|
158
159
|
}
|
|
159
|
-
exports._deepJsonEquals = _deepJsonEquals;
|
|
160
160
|
/**
|
|
161
161
|
* Shortcut for JSON.stringify(a) === JSON.stringify(b)
|
|
162
162
|
*
|
|
@@ -166,4 +166,3 @@ exports._deepJsonEquals = _deepJsonEquals;
|
|
|
166
166
|
function _jsonEquals(a, b) {
|
|
167
167
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
168
168
|
}
|
|
169
|
-
exports._jsonEquals = _jsonEquals;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._pick = _pick;
|
|
4
|
+
exports._omit = _omit;
|
|
5
|
+
exports._mask = _mask;
|
|
6
|
+
exports._filterFalsyValues = _filterFalsyValues;
|
|
7
|
+
exports._filterNullishValues = _filterNullishValues;
|
|
8
|
+
exports._filterUndefinedValues = _filterUndefinedValues;
|
|
9
|
+
exports._filterEmptyArrays = _filterEmptyArrays;
|
|
10
|
+
exports._filterObject = _filterObject;
|
|
11
|
+
exports._mapValues = _mapValues;
|
|
12
|
+
exports._mapKeys = _mapKeys;
|
|
13
|
+
exports._mapObject = _mapObject;
|
|
14
|
+
exports._findKeyByValue = _findKeyByValue;
|
|
15
|
+
exports._objectNullValuesToUndefined = _objectNullValuesToUndefined;
|
|
16
|
+
exports._deepCopy = _deepCopy;
|
|
17
|
+
exports._undefinedIfEmpty = _undefinedIfEmpty;
|
|
18
|
+
exports._filterEmptyValues = _filterEmptyValues;
|
|
19
|
+
exports._merge = _merge;
|
|
20
|
+
exports._deepTrim = _deepTrim;
|
|
21
|
+
exports._unset = _unset;
|
|
22
|
+
exports._invert = _invert;
|
|
23
|
+
exports._invertMap = _invertMap;
|
|
24
|
+
exports._get = _get;
|
|
25
|
+
exports._set = _set;
|
|
26
|
+
exports._has = _has;
|
|
27
|
+
exports._deepFreeze = _deepFreeze;
|
|
28
|
+
exports._objectAssignExact = _objectAssignExact;
|
|
4
29
|
const is_util_1 = require("../is.util");
|
|
5
30
|
const types_1 = require("../types");
|
|
6
31
|
/**
|
|
@@ -23,7 +48,6 @@ function _pick(obj, props, mutate = false) {
|
|
|
23
48
|
return r;
|
|
24
49
|
}, {});
|
|
25
50
|
}
|
|
26
|
-
exports._pick = _pick;
|
|
27
51
|
/**
|
|
28
52
|
* Returns clone of `obj` with `props` omitted.
|
|
29
53
|
* Opposite of Pick.
|
|
@@ -34,7 +58,6 @@ function _omit(obj, props, mutate = false) {
|
|
|
34
58
|
return r;
|
|
35
59
|
}, mutate ? obj : { ...obj });
|
|
36
60
|
}
|
|
37
|
-
exports._omit = _omit;
|
|
38
61
|
/**
|
|
39
62
|
* Returns object with filtered keys from `props` array.
|
|
40
63
|
* E.g:
|
|
@@ -49,21 +72,18 @@ function _mask(obj, props, mutate = false) {
|
|
|
49
72
|
return r;
|
|
50
73
|
}, mutate ? obj : _deepCopy(obj));
|
|
51
74
|
}
|
|
52
|
-
exports._mask = _mask;
|
|
53
75
|
/**
|
|
54
76
|
* Removes "falsy" values from the object.
|
|
55
77
|
*/
|
|
56
78
|
function _filterFalsyValues(obj, mutate = false) {
|
|
57
79
|
return _filterObject(obj, (_k, v) => !!v, mutate);
|
|
58
80
|
}
|
|
59
|
-
exports._filterFalsyValues = _filterFalsyValues;
|
|
60
81
|
/**
|
|
61
82
|
* Removes values from the object that are `null` or `undefined`.
|
|
62
83
|
*/
|
|
63
84
|
function _filterNullishValues(obj, mutate = false) {
|
|
64
85
|
return _filterObject(obj, (_k, v) => v !== undefined && v !== null, mutate);
|
|
65
86
|
}
|
|
66
|
-
exports._filterNullishValues = _filterNullishValues;
|
|
67
87
|
/**
|
|
68
88
|
* Removes values from the object that are `undefined`.
|
|
69
89
|
* Only `undefined` values are removed. `null` values are kept!
|
|
@@ -71,11 +91,9 @@ exports._filterNullishValues = _filterNullishValues;
|
|
|
71
91
|
function _filterUndefinedValues(obj, mutate = false) {
|
|
72
92
|
return _filterObject(obj, (_k, v) => v !== undefined, mutate);
|
|
73
93
|
}
|
|
74
|
-
exports._filterUndefinedValues = _filterUndefinedValues;
|
|
75
94
|
function _filterEmptyArrays(obj, mutate = false) {
|
|
76
95
|
return _filterObject(obj, (_k, v) => !Array.isArray(v) || v.length > 0, mutate);
|
|
77
96
|
}
|
|
78
|
-
exports._filterEmptyArrays = _filterEmptyArrays;
|
|
79
97
|
/**
|
|
80
98
|
* Returns clone of `obj` without properties that does not pass `predicate`.
|
|
81
99
|
* Allows filtering by both key and value.
|
|
@@ -87,7 +105,6 @@ function _filterObject(obj, predicate, mutate = false) {
|
|
|
87
105
|
return r;
|
|
88
106
|
}, mutate ? obj : { ...obj });
|
|
89
107
|
}
|
|
90
|
-
exports._filterObject = _filterObject;
|
|
91
108
|
/**
|
|
92
109
|
* var users = {
|
|
93
110
|
* 'fred': { 'user': 'fred', 'age': 40 },
|
|
@@ -105,7 +122,6 @@ function _mapValues(obj, mapper, mutate = false) {
|
|
|
105
122
|
return map;
|
|
106
123
|
}, mutate ? obj : {});
|
|
107
124
|
}
|
|
108
|
-
exports._mapValues = _mapValues;
|
|
109
125
|
/**
|
|
110
126
|
* _.mapKeys({ 'a': 1, 'b': 2 }, (key, value) => key + value)
|
|
111
127
|
* // => { 'a1': 1, 'b2': 2 }
|
|
@@ -120,7 +136,6 @@ function _mapKeys(obj, mapper) {
|
|
|
120
136
|
return map;
|
|
121
137
|
}, {});
|
|
122
138
|
}
|
|
123
|
-
exports._mapKeys = _mapKeys;
|
|
124
139
|
/**
|
|
125
140
|
* Maps object through predicate - a function that receives (k, v, obj)
|
|
126
141
|
* k - key
|
|
@@ -146,22 +161,18 @@ function _mapObject(obj, mapper) {
|
|
|
146
161
|
return map;
|
|
147
162
|
}, {});
|
|
148
163
|
}
|
|
149
|
-
exports._mapObject = _mapObject;
|
|
150
164
|
function _findKeyByValue(obj, v) {
|
|
151
165
|
return Object.entries(obj).find(([_, value]) => value === v)?.[0];
|
|
152
166
|
}
|
|
153
|
-
exports._findKeyByValue = _findKeyByValue;
|
|
154
167
|
function _objectNullValuesToUndefined(obj, mutate = false) {
|
|
155
168
|
return _mapValues(obj, (_k, v) => (v === null ? undefined : v), mutate);
|
|
156
169
|
}
|
|
157
|
-
exports._objectNullValuesToUndefined = _objectNullValuesToUndefined;
|
|
158
170
|
/**
|
|
159
171
|
* Deep copy object (by json parse/stringify, since it has unbeatable performance+simplicity combo).
|
|
160
172
|
*/
|
|
161
173
|
function _deepCopy(o, reviver) {
|
|
162
174
|
return JSON.parse(JSON.stringify(o), reviver);
|
|
163
175
|
}
|
|
164
|
-
exports._deepCopy = _deepCopy;
|
|
165
176
|
/**
|
|
166
177
|
* Returns `undefined` if it's empty (according to `_isEmpty()` specification),
|
|
167
178
|
* otherwise returns the original object.
|
|
@@ -169,14 +180,12 @@ exports._deepCopy = _deepCopy;
|
|
|
169
180
|
function _undefinedIfEmpty(obj) {
|
|
170
181
|
return (0, is_util_1._isEmpty)(obj) ? undefined : obj;
|
|
171
182
|
}
|
|
172
|
-
exports._undefinedIfEmpty = _undefinedIfEmpty;
|
|
173
183
|
/**
|
|
174
184
|
* Filters the object by removing all key-value pairs where Value is Empty (according to _isEmpty() specification).
|
|
175
185
|
*/
|
|
176
186
|
function _filterEmptyValues(obj, mutate = false) {
|
|
177
187
|
return _filterObject(obj, (_k, v) => !(0, is_util_1._isEmpty)(v), mutate);
|
|
178
188
|
}
|
|
179
|
-
exports._filterEmptyValues = _filterEmptyValues;
|
|
180
189
|
/**
|
|
181
190
|
* Recursively merges own and inherited enumerable properties of source
|
|
182
191
|
* objects into the destination object, skipping source properties that resolve
|
|
@@ -226,7 +235,6 @@ function _merge(target, ...sources) {
|
|
|
226
235
|
});
|
|
227
236
|
return target;
|
|
228
237
|
}
|
|
229
|
-
exports._merge = _merge;
|
|
230
238
|
/**
|
|
231
239
|
* Trims all object VALUES deeply.
|
|
232
240
|
* Doesn't touch object KEYS.
|
|
@@ -245,7 +253,6 @@ function _deepTrim(o) {
|
|
|
245
253
|
}
|
|
246
254
|
return o;
|
|
247
255
|
}
|
|
248
|
-
exports._deepTrim = _deepTrim;
|
|
249
256
|
// from: https://github.com/jonschlinkert/unset-value
|
|
250
257
|
// mutates obj
|
|
251
258
|
function _unset(obj, prop) {
|
|
@@ -270,7 +277,6 @@ function _unset(obj, prop) {
|
|
|
270
277
|
return;
|
|
271
278
|
delete obj[last];
|
|
272
279
|
}
|
|
273
|
-
exports._unset = _unset;
|
|
274
280
|
function _invert(o) {
|
|
275
281
|
const inv = {};
|
|
276
282
|
Object.keys(o).forEach(k => {
|
|
@@ -278,13 +284,11 @@ function _invert(o) {
|
|
|
278
284
|
});
|
|
279
285
|
return inv;
|
|
280
286
|
}
|
|
281
|
-
exports._invert = _invert;
|
|
282
287
|
function _invertMap(m) {
|
|
283
288
|
const inv = new Map();
|
|
284
289
|
m.forEach((v, k) => inv.set(v, k));
|
|
285
290
|
return inv;
|
|
286
291
|
}
|
|
287
|
-
exports._invertMap = _invertMap;
|
|
288
292
|
/**
|
|
289
293
|
* Gets the property value at path of object.
|
|
290
294
|
*
|
|
@@ -301,7 +305,6 @@ function _get(obj = {}, path = '') {
|
|
|
301
305
|
.split('.')
|
|
302
306
|
.reduce((o, p) => o?.[p], obj);
|
|
303
307
|
}
|
|
304
|
-
exports._get = _get;
|
|
305
308
|
/**
|
|
306
309
|
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. Arrays are created for
|
|
307
310
|
* missing index properties while objects are created for all other missing properties.
|
|
@@ -336,7 +339,6 @@ function _set(obj, path, value) {
|
|
|
336
339
|
obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
|
|
337
340
|
return obj; // allow chaining
|
|
338
341
|
}
|
|
339
|
-
exports._set = _set;
|
|
340
342
|
/**
|
|
341
343
|
* Checks if `path` is a direct property of `object` (not null, not undefined).
|
|
342
344
|
*
|
|
@@ -365,7 +367,6 @@ function _has(obj, path) {
|
|
|
365
367
|
const v = _get(obj, path);
|
|
366
368
|
return v !== undefined && v !== null;
|
|
367
369
|
}
|
|
368
|
-
exports._has = _has;
|
|
369
370
|
/**
|
|
370
371
|
* Does Object.freeze recursively for given object.
|
|
371
372
|
*
|
|
@@ -382,7 +383,6 @@ function _deepFreeze(o) {
|
|
|
382
383
|
}
|
|
383
384
|
});
|
|
384
385
|
}
|
|
385
|
-
exports._deepFreeze = _deepFreeze;
|
|
386
386
|
/**
|
|
387
387
|
* let target: T = { a: 'a', n: 1}
|
|
388
388
|
* let source: T = { a: 'a2', b: 'b' }
|
|
@@ -409,4 +409,3 @@ function _objectAssignExact(target, source) {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
exports._objectAssignExact = _objectAssignExact;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._sortObject =
|
|
3
|
+
exports._sortObject = _sortObject;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
5
|
/**
|
|
6
6
|
* Returns new object with keys sorder in the given order.
|
|
@@ -19,4 +19,3 @@ function _sortObject(obj, keyOrder) {
|
|
|
19
19
|
});
|
|
20
20
|
return r;
|
|
21
21
|
}
|
|
22
|
-
exports._sortObject = _sortObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._sortObjectDeep =
|
|
3
|
+
exports._sortObjectDeep = _sortObjectDeep;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
/**
|
|
6
6
|
* based on: https://github.com/IndigoUnited/js-deep-sort-object
|
|
@@ -21,4 +21,3 @@ function _sortObjectDeep(o) {
|
|
|
21
21
|
}
|
|
22
22
|
return o;
|
|
23
23
|
}
|
|
24
|
-
exports._sortObjectDeep = _sortObjectDeep;
|
package/dist/polyfill.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.polyfillDispose =
|
|
3
|
+
exports.polyfillDispose = polyfillDispose;
|
|
4
4
|
function polyfillDispose() {
|
|
5
5
|
// @ts-expect-error polyfill
|
|
6
6
|
Symbol.dispose ??= Symbol('Symbol.dispose');
|
|
7
7
|
// @ts-expect-error polyfill
|
|
8
8
|
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose');
|
|
9
9
|
}
|
|
10
|
-
exports.polyfillDispose = polyfillDispose;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Abortable = void 0;
|
|
4
|
+
exports.abortable = abortable;
|
|
4
5
|
/**
|
|
5
6
|
* Similar to AbortController and AbortSignal.
|
|
6
7
|
* Similar to pDefer and Promise.
|
|
@@ -33,4 +34,3 @@ exports.Abortable = Abortable;
|
|
|
33
34
|
function abortable(onAbort) {
|
|
34
35
|
return new Abortable(onAbort);
|
|
35
36
|
}
|
|
36
|
-
exports.abortable = abortable;
|
package/dist/promise/pDefer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pDefer =
|
|
3
|
+
exports.pDefer = pDefer;
|
|
4
4
|
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
5
5
|
/**
|
|
6
6
|
* Returns DeferredPromise - a Promise that has .resolve() and .reject() methods.
|
|
@@ -18,4 +18,3 @@ function pDefer() {
|
|
|
18
18
|
promise.abort = reason => promise.rejectAborted(reason);
|
|
19
19
|
return promise;
|
|
20
20
|
}
|
|
21
|
-
exports.pDefer = pDefer;
|
package/dist/promise/pDelay.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.pDelay = pDelay;
|
|
4
|
+
exports.pDelayFn = pDelayFn;
|
|
4
5
|
const pDefer_1 = require("./pDefer");
|
|
5
6
|
/**
|
|
6
7
|
* Promisified version of setTimeout.
|
|
@@ -11,7 +12,6 @@ const pDefer_1 = require("./pDefer");
|
|
|
11
12
|
async function pDelay(ms = 0, value) {
|
|
12
13
|
return await new Promise((resolve, reject) => setTimeout(value instanceof Error ? reject : resolve, ms, value));
|
|
13
14
|
}
|
|
14
|
-
exports.pDelay = pDelay;
|
|
15
15
|
/* eslint-disable @typescript-eslint/promise-function-async */
|
|
16
16
|
/**
|
|
17
17
|
* Promisified version of setTimeout.
|
|
@@ -39,4 +39,3 @@ function pDelayFn(ms = 0, fn) {
|
|
|
39
39
|
};
|
|
40
40
|
return p;
|
|
41
41
|
}
|
|
42
|
-
exports.pDelayFn = pDelayFn;
|
package/dist/promise/pFilter.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pFilter =
|
|
3
|
+
exports.pFilter = pFilter;
|
|
4
4
|
async function pFilter(iterable, filterFn) {
|
|
5
5
|
const items = [...iterable];
|
|
6
6
|
const predicates = await Promise.all(items.map((item, i) => filterFn(item, i)));
|
|
7
7
|
return items.filter((item, i) => predicates[i]);
|
|
8
8
|
}
|
|
9
|
-
exports.pFilter = pFilter;
|
package/dist/promise/pHang.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pHang =
|
|
3
|
+
exports.pHang = pHang;
|
|
4
4
|
/**
|
|
5
5
|
* Returns Promise that never resolves ("hanging").
|
|
6
6
|
*/
|
|
7
7
|
async function pHang() {
|
|
8
8
|
return await new Promise(() => void 0);
|
|
9
9
|
}
|
|
10
|
-
exports.pHang = pHang;
|
package/dist/promise/pMap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pMap =
|
|
3
|
+
exports.pMap = pMap;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
/**
|
|
6
6
|
* Forked from https://github.com/sindresorhus/p-map
|
|
@@ -114,7 +114,6 @@ async function pMap(iterable, mapper, opt = {}) {
|
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
exports.pMap = pMap;
|
|
118
117
|
/**
|
|
119
118
|
pMap with serial (non-concurrent) execution.
|
|
120
119
|
*/
|
package/dist/promise/pProps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pProps =
|
|
3
|
+
exports.pProps = pProps;
|
|
4
4
|
/**
|
|
5
5
|
* Promise.all for Object instead of Array.
|
|
6
6
|
*
|
|
@@ -21,4 +21,3 @@ async function pProps(input) {
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
22
22
|
return Object.fromEntries((await Promise.all(Object.values(input))).map((v, i) => [keys[i], v]));
|
|
23
23
|
}
|
|
24
|
-
exports.pProps = pProps;
|
package/dist/promise/pRetry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.pRetryFn = pRetryFn;
|
|
4
|
+
exports.pRetry = pRetry;
|
|
4
5
|
const __1 = require("..");
|
|
5
6
|
/**
|
|
6
7
|
* Returns a Function (!), enhanced with retry capabilities.
|
|
@@ -11,7 +12,6 @@ function pRetryFn(fn, opt = {}) {
|
|
|
11
12
|
return await pRetry(() => fn.call(this, ...args), opt);
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
exports.pRetryFn = pRetryFn;
|
|
15
15
|
async function pRetry(fn, opt = {}) {
|
|
16
16
|
const { maxAttempts = 4, delay: initialDelay = 1000, delayMultiplier = 2, predicate, logger = console, name, timeout, } = opt;
|
|
17
17
|
const fakeError = timeout ? new Error('TimeoutError') : undefined;
|
|
@@ -64,4 +64,3 @@ async function pRetry(fn, opt = {}) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
exports.pRetry = pRetry;
|
package/dist/promise/pState.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pState =
|
|
3
|
+
exports.pState = pState;
|
|
4
4
|
const UNIQUE_VALUE = Symbol('unique');
|
|
5
5
|
/**
|
|
6
6
|
* Returns the state of the Promise, one of:
|
|
@@ -15,4 +15,3 @@ async function pState(p) {
|
|
|
15
15
|
return v === UNIQUE_VALUE ? 'pending' : 'resolved';
|
|
16
16
|
}, () => 'rejected');
|
|
17
17
|
}
|
|
18
|
-
exports.pState = pState;
|
package/dist/promise/pTimeout.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.pTimeoutFn = pTimeoutFn;
|
|
4
|
+
exports.pTimeout = pTimeout;
|
|
4
5
|
const error_util_1 = require("../error/error.util");
|
|
5
6
|
/**
|
|
6
7
|
* Decorates a Function with a timeout.
|
|
@@ -18,7 +19,6 @@ function pTimeoutFn(fn, opt) {
|
|
|
18
19
|
return await pTimeout(() => fn.apply(this, args), opt);
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
exports.pTimeoutFn = pTimeoutFn;
|
|
22
22
|
/**
|
|
23
23
|
* Decorates a Function with a timeout and immediately calls it.
|
|
24
24
|
*
|
|
@@ -64,4 +64,3 @@ async function pTimeout(fn, opt) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
exports.pTimeout = pTimeout;
|
package/dist/semver.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.semver2 = exports.Semver = void 0;
|
|
4
|
+
exports._quickSemverCompare = _quickSemverCompare;
|
|
4
5
|
const range_1 = require("./array/range");
|
|
5
6
|
const assert_1 = require("./error/assert");
|
|
6
7
|
const is_util_1 = require("./is.util");
|
|
@@ -141,4 +142,3 @@ function _quickSemverCompare(a, b) {
|
|
|
141
142
|
.join('');
|
|
142
143
|
return s1 < s2 ? -1 : s1 > s2 ? 1 : 0;
|
|
143
144
|
}
|
|
144
|
-
exports._quickSemverCompare = _quickSemverCompare;
|
package/dist/string/case.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._camelCase = _camelCase;
|
|
4
|
+
exports._snakeCase = _snakeCase;
|
|
5
|
+
exports._kebabCase = _kebabCase;
|
|
4
6
|
const words_1 = require("./lodash/words");
|
|
5
7
|
const string_util_1 = require("./string.util");
|
|
6
8
|
function _camelCase(s) {
|
|
@@ -10,12 +12,9 @@ function _camelCase(s) {
|
|
|
10
12
|
return result + (index ? (0, string_util_1._upperFirst)(word) : word);
|
|
11
13
|
}, '');
|
|
12
14
|
}
|
|
13
|
-
exports._camelCase = _camelCase;
|
|
14
15
|
function _snakeCase(s) {
|
|
15
16
|
return (0, words_1.words)(s.replaceAll(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '_' : '') + word.toLowerCase(), '');
|
|
16
17
|
}
|
|
17
|
-
exports._snakeCase = _snakeCase;
|
|
18
18
|
function _kebabCase(s) {
|
|
19
19
|
return (0, words_1.words)(s.replaceAll(/['\u2019]/g, '')).reduce((result, word, index) => result + (index ? '-' : '') + word.toLowerCase(), '');
|
|
20
20
|
}
|
|
21
|
-
exports._kebabCase = _kebabCase;
|
package/dist/string/escape.js
CHANGED
|
@@ -12,7 +12,8 @@ Reasons:
|
|
|
12
12
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.htmlEscape = htmlEscape;
|
|
16
|
+
exports.htmlUnescape = htmlUnescape;
|
|
16
17
|
// Multiple `.replace()` calls are actually faster than using replacer functions
|
|
17
18
|
function _htmlEscape(s) {
|
|
18
19
|
return s
|
|
@@ -40,7 +41,6 @@ function htmlEscape(strings, ...values) {
|
|
|
40
41
|
}
|
|
41
42
|
return output;
|
|
42
43
|
}
|
|
43
|
-
exports.htmlEscape = htmlEscape;
|
|
44
44
|
function htmlUnescape(strings, ...values) {
|
|
45
45
|
if (typeof strings === 'string') {
|
|
46
46
|
return _htmlUnescape(strings);
|
|
@@ -51,4 +51,3 @@ function htmlUnescape(strings, ...values) {
|
|
|
51
51
|
}
|
|
52
52
|
return output;
|
|
53
53
|
}
|
|
54
|
-
exports.htmlUnescape = htmlUnescape;
|