@naturalcycles/js-lib 14.70.0 → 14.72.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/error/error.util.js +2 -0
- package/dist/error/try.d.ts +1 -1
- package/dist/error/try.js +2 -0
- package/dist/index.d.ts +28 -26
- package/dist/index.js +28 -122
- package/dist/math/sma.d.ts +2 -2
- package/dist/math/stack.util.d.ts +21 -0
- package/dist/math/stack.util.js +36 -0
- package/dist/promise/pBatch.d.ts +2 -3
- package/dist/promise/pFilter.d.ts +2 -2
- package/dist/promise/pMap.d.ts +2 -3
- package/dist/promise/pMap.js +13 -7
- package/dist/promise/pProps.d.ts +3 -1
- package/dist/promise/pProps.js +4 -5
- package/dist/seq/seq.d.ts +30 -0
- package/dist/seq/seq.js +141 -0
- package/dist/string/json.util.js +4 -1
- package/dist/typeFest.d.ts +0 -30
- package/dist/types.d.ts +13 -1
- package/dist/types.js +9 -1
- package/dist-esm/error/error.util.js +2 -0
- package/dist-esm/error/try.js +2 -0
- package/dist-esm/index.js +26 -24
- package/dist-esm/math/stack.util.js +32 -0
- package/dist-esm/promise/pMap.js +14 -8
- package/dist-esm/promise/pProps.js +4 -5
- package/dist-esm/seq/seq.js +136 -0
- package/dist-esm/string/json.util.js +4 -1
- package/dist-esm/types.js +8 -0
- package/package.json +1 -1
- package/src/error/error.util.ts +2 -0
- package/src/error/try.ts +4 -1
- package/src/index.ts +36 -195
- package/src/math/sma.ts +1 -1
- package/src/math/stack.util.ts +35 -0
- package/src/promise/pBatch.ts +2 -3
- package/src/promise/pFilter.ts +2 -2
- package/src/promise/pMap.ts +16 -11
- package/src/promise/pProps.ts +6 -7
- package/src/seq/seq.ts +143 -0
- package/src/string/json.util.ts +5 -1
- package/src/typeFest.ts +0 -32
- package/src/types.ts +22 -1
package/dist/error/error.util.js
CHANGED
|
@@ -67,6 +67,8 @@ function _errorObjectToAppError(o) {
|
|
|
67
67
|
}
|
|
68
68
|
exports._errorObjectToAppError = _errorObjectToAppError;
|
|
69
69
|
function _errorObjectToError(o, errorClass = Error) {
|
|
70
|
+
if (o instanceof errorClass)
|
|
71
|
+
return o;
|
|
70
72
|
const err = new errorClass(o.message);
|
|
71
73
|
// name: err.name, // cannot be assigned to a readonly property like this
|
|
72
74
|
// stack: o.stack, // also readonly e.g in Firefox
|
package/dist/error/try.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export declare function _try<ERR = unknown, RETURN = void>(fn: () => RETURN): [e
|
|
|
21
21
|
* Also, intentionally types second return item as non-optional,
|
|
22
22
|
* but you should check for `err` presense first!
|
|
23
23
|
*/
|
|
24
|
-
export declare function pTry<ERR = unknown, RETURN = void>(promise: Promise<RETURN>): Promise<[err: ERR | null, value: RETURN]>;
|
|
24
|
+
export declare function pTry<ERR = unknown, RETURN = void>(promise: Promise<RETURN>): Promise<[err: ERR | null, value: Awaited<RETURN>]>;
|
package/dist/error/try.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export * from './array/array.util';
|
|
2
|
+
export * from './lazy';
|
|
3
|
+
export * from './string/url.util';
|
|
4
|
+
export * from './array/range';
|
|
5
5
|
import { PromiseDecoratorCfg, PromiseDecoratorResp, _createPromiseDecorator } from './decorators/createPromiseDecorator';
|
|
6
6
|
import { _debounce, _throttle } from './decorators/debounce';
|
|
7
7
|
import { _Debounce, _Throttle } from './decorators/debounce.decorator';
|
|
@@ -25,37 +25,39 @@ import { JSON_SCHEMA_ORDER } from './json-schema/jsonSchema.cnst';
|
|
|
25
25
|
import { JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBoolean, JsonSchemaConst, JsonSchemaEnum, JsonSchemaNot, JsonSchemaNull, JsonSchemaNumber, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaOneOf, JsonSchemaRef, JsonSchemaString, JsonSchemaTuple } from './json-schema/jsonSchema.model';
|
|
26
26
|
import { mergeJsonSchemaObjects } from './json-schema/jsonSchema.util';
|
|
27
27
|
import { jsonSchema, JsonSchemaAnyBuilder, JsonSchemaBuilder } from './json-schema/jsonSchemaBuilder';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export * from './math/math.util';
|
|
29
|
+
export * from './math/sma';
|
|
30
|
+
export * from './number/createDeterministicRandom';
|
|
31
|
+
export * from './number/number.util';
|
|
32
|
+
export * from './object/deepEquals';
|
|
33
|
+
export * from './object/object.util';
|
|
34
|
+
export * from './object/sortObject';
|
|
35
|
+
export * from './object/sortObjectDeep';
|
|
36
36
|
import { AggregatedError } from './promise/AggregatedError';
|
|
37
|
-
|
|
37
|
+
export * from './promise/pBatch';
|
|
38
38
|
import { DeferredPromise, pDefer } from './promise/pDefer';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
export * from './promise/pDelay';
|
|
40
|
+
export * from './promise/pFilter';
|
|
41
|
+
export * from './promise/pHang';
|
|
42
42
|
import { pMap, PMapOptions } from './promise/pMap';
|
|
43
|
-
|
|
43
|
+
export * from './promise/pProps';
|
|
44
44
|
import { pRetry, PRetryOptions } from './promise/pRetry';
|
|
45
|
-
|
|
45
|
+
export * from './promise/pState';
|
|
46
46
|
import { pTimeout, PTimeoutOptions } from './promise/pTimeout';
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
export * from './promise/pTuple';
|
|
48
|
+
export * from './string/case';
|
|
49
|
+
export * from './string/json.util';
|
|
50
|
+
export * from './string/string.util';
|
|
51
51
|
import { JsonStringifyFunction, StringifyAnyOptions, _stringifyAny } from './string/stringifyAny';
|
|
52
52
|
import { _ms, _since } from './time/time.util';
|
|
53
|
-
import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable,
|
|
54
|
-
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, BatchResult, InstanceId, IsoDate, IsoDateTime, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestamp, ValueOf, ValuesOf, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
|
|
53
|
+
import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, ReadonlyDeep, Simplify } from './typeFest';
|
|
54
|
+
import { AsyncMapper, AsyncPredicate, BaseDBEntity, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, Saved, Unsaved, BatchResult, InstanceId, IsoDate, IsoDateTime, KeyValueTuple, Mapper, ObjectMapper, ObjectPredicate, Predicate, PromiseMap, AnyObject, AnyFunction, Reviver, SavedDBEntity, StringMap, UnixTimestamp, ValueOf, ValuesOf, AbortableMapper, AbortableAsyncPredicate, AbortableAsyncMapper, AbortablePredicate, END, SKIP, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues } from './types';
|
|
55
55
|
import { _gb, _hb, _kb, _mb } from './unit/size.util';
|
|
56
56
|
import { is } from './vendor/is';
|
|
57
57
|
import { CommonLogLevel, CommonLogFunction, CommonLogger, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, CommonLogWithLevelFunction, commonLoggerCreate } from './log/commonLogger';
|
|
58
58
|
import { _safeJsonStringify } from './string/safeJsonStringify';
|
|
59
59
|
import { PQueue, PQueueCfg } from './promise/pQueue';
|
|
60
|
-
export
|
|
61
|
-
export
|
|
60
|
+
export * from './seq/seq';
|
|
61
|
+
export * from './math/stack.util';
|
|
62
|
+
export type { AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, PromiseDecoratorCfg, PromiseDecoratorResp, ErrorData, ErrorObject, HttpErrorData, HttpErrorResponse, Admin401ErrorData, Admin403ErrorData, StringMap, PromiseMap, AnyObject, AnyFunction, ValuesOf, ValueOf, KeyValueTuple, ObjectMapper, ObjectPredicate, InstanceId, IsoDate, IsoDateTime, Reviver, PMapOptions, Mapper, AsyncMapper, Predicate, AsyncPredicate, BatchResult, DeferredPromise, PRetryOptions, PTimeoutOptions, TryCatchOptions, StringifyAnyOptions, JsonStringifyFunction, Merge, ReadonlyDeep, Promisable, Simplify, ConditionalPick, ConditionalExcept, Class, UnixTimestamp, BaseDBEntity, SavedDBEntity, Saved, Unsaved, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
|
|
63
|
+
export { is, _Memo, _memoFn, _LogMethod, _getArgsSignature, _createPromiseDecorator, AppError, HttpError, AssertionError, _assert, _assertEquals, _assertDeepEquals, _assertIsError, _assertIsString, _assertIsNumber, _assertTypeOf, _stringMapValues, _stringMapEntries, _objectKeys, _debounce, _throttle, _Debounce, _Throttle, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, ErrorMode, pDefer, AggregatedError, pRetry, pTimeout, _Retry, _Timeout, _tryCatch, _TryCatch, _try, pTry, _stringifyAny, _ms, _since, _hb, _gb, _mb, _kb, mergeJsonSchemaObjects, jsonSchema, JsonSchemaAnyBuilder, JSON_SCHEMA_ORDER, generateJsonSchemaFromData, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, _safeJsonStringify, PQueue, END, SKIP, };
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.commonLoggerNoop = exports.commonLoggerMinLevel = exports._lazyValue = exports._defineLazyProps = exports._defineLazyProperty = exports._parseQueryString = exports.generateJsonSchemaFromData = exports.JSON_SCHEMA_ORDER = exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports.mergeJsonSchemaObjects = exports._last = exports._clamp = exports._sumBy = exports._sum = exports._kebabCase = exports._camelCase = exports._snakeCase = exports._kb = exports._mb = exports._gb = exports._hb = exports._since = exports._ms = exports._stringifyAny = exports._jsonParseIfPossible = exports.pTry = exports._try = exports._TryCatch = exports._tryCatch = exports._Timeout = exports._Retry = exports.pTuple = exports.pTimeout = exports.pRetry = exports.AggregatedError = exports.pState = exports.pHang = exports.pDefer = exports.pDelay = exports.pProps = exports.pFilter = exports.ErrorMode = exports.pBatch = exports._noop = exports._passNothingPredicate = exports._passthroughPredicate = exports._passUndefinedMapper = exports._passthroughMapper = exports.pMap = void 0;
|
|
6
|
-
exports.PQueue = exports._safeJsonStringify = exports.commonLoggerCreate = exports.commonLoggerPrefix = exports.commonLoggerPipe = exports.commonLogLevelNumber = void 0;
|
|
3
|
+
exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports.mergeJsonSchemaObjects = exports._kb = exports._mb = exports._gb = exports._hb = exports._since = exports._ms = exports._stringifyAny = exports.pTry = exports._try = exports._TryCatch = exports._tryCatch = exports._Timeout = exports._Retry = exports.pTimeout = exports.pRetry = exports.AggregatedError = exports.pDefer = exports.ErrorMode = exports._noop = exports._passNothingPredicate = exports._passthroughPredicate = exports._passUndefinedMapper = exports._passthroughMapper = exports.pMap = exports._Throttle = exports._Debounce = exports._throttle = exports._debounce = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._assertTypeOf = exports._assertIsNumber = exports._assertIsString = exports._assertIsError = exports._assertDeepEquals = exports._assertEquals = exports._assert = exports.AssertionError = exports.HttpError = exports.AppError = exports._createPromiseDecorator = exports._getArgsSignature = exports._LogMethod = exports._memoFn = exports._Memo = exports.is = void 0;
|
|
4
|
+
exports.SKIP = exports.END = exports.PQueue = exports._safeJsonStringify = exports.commonLoggerCreate = exports.commonLoggerPrefix = exports.commonLoggerPipe = exports.commonLogLevelNumber = exports.commonLoggerNoop = exports.commonLoggerMinLevel = exports.generateJsonSchemaFromData = exports.JSON_SCHEMA_ORDER = void 0;
|
|
7
5
|
const tslib_1 = require("tslib");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "_difference", { enumerable: true, get: function () { return array_util_1._difference; } });
|
|
13
|
-
Object.defineProperty(exports, "_dropRightWhile", { enumerable: true, get: function () { return array_util_1._dropRightWhile; } });
|
|
14
|
-
Object.defineProperty(exports, "_dropWhile", { enumerable: true, get: function () { return array_util_1._dropWhile; } });
|
|
15
|
-
Object.defineProperty(exports, "_findLast", { enumerable: true, get: function () { return array_util_1._findLast; } });
|
|
16
|
-
Object.defineProperty(exports, "_flatten", { enumerable: true, get: function () { return array_util_1._flatten; } });
|
|
17
|
-
Object.defineProperty(exports, "_flattenDeep", { enumerable: true, get: function () { return array_util_1._flattenDeep; } });
|
|
18
|
-
Object.defineProperty(exports, "_groupBy", { enumerable: true, get: function () { return array_util_1._groupBy; } });
|
|
19
|
-
Object.defineProperty(exports, "_intersection", { enumerable: true, get: function () { return array_util_1._intersection; } });
|
|
20
|
-
Object.defineProperty(exports, "_last", { enumerable: true, get: function () { return array_util_1._last; } });
|
|
21
|
-
Object.defineProperty(exports, "_mapToObject", { enumerable: true, get: function () { return array_util_1._mapToObject; } });
|
|
22
|
-
Object.defineProperty(exports, "_shuffle", { enumerable: true, get: function () { return array_util_1._shuffle; } });
|
|
23
|
-
Object.defineProperty(exports, "_sortBy", { enumerable: true, get: function () { return array_util_1._sortBy; } });
|
|
24
|
-
Object.defineProperty(exports, "_sum", { enumerable: true, get: function () { return array_util_1._sum; } });
|
|
25
|
-
Object.defineProperty(exports, "_sumBy", { enumerable: true, get: function () { return array_util_1._sumBy; } });
|
|
26
|
-
Object.defineProperty(exports, "_takeRightWhile", { enumerable: true, get: function () { return array_util_1._takeRightWhile; } });
|
|
27
|
-
Object.defineProperty(exports, "_takeWhile", { enumerable: true, get: function () { return array_util_1._takeWhile; } });
|
|
28
|
-
Object.defineProperty(exports, "_uniq", { enumerable: true, get: function () { return array_util_1._uniq; } });
|
|
29
|
-
Object.defineProperty(exports, "_uniqBy", { enumerable: true, get: function () { return array_util_1._uniqBy; } });
|
|
30
|
-
const lazy_1 = require("./lazy");
|
|
31
|
-
Object.defineProperty(exports, "_defineLazyProperty", { enumerable: true, get: function () { return lazy_1._defineLazyProperty; } });
|
|
32
|
-
Object.defineProperty(exports, "_defineLazyProps", { enumerable: true, get: function () { return lazy_1._defineLazyProps; } });
|
|
33
|
-
Object.defineProperty(exports, "_lazyValue", { enumerable: true, get: function () { return lazy_1._lazyValue; } });
|
|
34
|
-
const url_util_1 = require("./string/url.util");
|
|
35
|
-
Object.defineProperty(exports, "_parseQueryString", { enumerable: true, get: function () { return url_util_1._parseQueryString; } });
|
|
36
|
-
const range_1 = require("./array/range");
|
|
37
|
-
Object.defineProperty(exports, "_range", { enumerable: true, get: function () { return range_1._range; } });
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./array/array.util"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./lazy"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./string/url.util"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./array/range"), exports);
|
|
38
10
|
const createPromiseDecorator_1 = require("./decorators/createPromiseDecorator");
|
|
39
11
|
Object.defineProperty(exports, "_createPromiseDecorator", { enumerable: true, get: function () { return createPromiseDecorator_1._createPromiseDecorator; } });
|
|
40
12
|
const debounce_1 = require("./decorators/debounce");
|
|
@@ -86,110 +58,42 @@ Object.defineProperty(exports, "mergeJsonSchemaObjects", { enumerable: true, get
|
|
|
86
58
|
const jsonSchemaBuilder_1 = require("./json-schema/jsonSchemaBuilder");
|
|
87
59
|
Object.defineProperty(exports, "jsonSchema", { enumerable: true, get: function () { return jsonSchemaBuilder_1.jsonSchema; } });
|
|
88
60
|
Object.defineProperty(exports, "JsonSchemaAnyBuilder", { enumerable: true, get: function () { return jsonSchemaBuilder_1.JsonSchemaAnyBuilder; } });
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Object.defineProperty(exports, "_createDeterministicRandom", { enumerable: true, get: function () { return createDeterministicRandom_1._createDeterministicRandom; } });
|
|
98
|
-
const number_util_1 = require("./number/number.util");
|
|
99
|
-
Object.defineProperty(exports, "_clamp", { enumerable: true, get: function () { return number_util_1._clamp; } });
|
|
100
|
-
Object.defineProperty(exports, "_inRange", { enumerable: true, get: function () { return number_util_1._inRange; } });
|
|
101
|
-
Object.defineProperty(exports, "_randomInt", { enumerable: true, get: function () { return number_util_1._randomInt; } });
|
|
102
|
-
Object.defineProperty(exports, "_randomArrayItem", { enumerable: true, get: function () { return number_util_1._randomArrayItem; } });
|
|
103
|
-
Object.defineProperty(exports, "_round", { enumerable: true, get: function () { return number_util_1._round; } });
|
|
104
|
-
Object.defineProperty(exports, "_sortNumbers", { enumerable: true, get: function () { return number_util_1._sortNumbers; } });
|
|
105
|
-
Object.defineProperty(exports, "_toFixed", { enumerable: true, get: function () { return number_util_1._toFixed; } });
|
|
106
|
-
Object.defineProperty(exports, "_toPrecision", { enumerable: true, get: function () { return number_util_1._toPrecision; } });
|
|
107
|
-
const deepEquals_1 = require("./object/deepEquals");
|
|
108
|
-
Object.defineProperty(exports, "_deepEquals", { enumerable: true, get: function () { return deepEquals_1._deepEquals; } });
|
|
109
|
-
const object_util_1 = require("./object/object.util");
|
|
110
|
-
Object.defineProperty(exports, "_deepCopy", { enumerable: true, get: function () { return object_util_1._deepCopy; } });
|
|
111
|
-
Object.defineProperty(exports, "_deepTrim", { enumerable: true, get: function () { return object_util_1._deepTrim; } });
|
|
112
|
-
Object.defineProperty(exports, "_filterEmptyArrays", { enumerable: true, get: function () { return object_util_1._filterEmptyArrays; } });
|
|
113
|
-
Object.defineProperty(exports, "_filterEmptyValues", { enumerable: true, get: function () { return object_util_1._filterEmptyValues; } });
|
|
114
|
-
Object.defineProperty(exports, "_filterFalsyValues", { enumerable: true, get: function () { return object_util_1._filterFalsyValues; } });
|
|
115
|
-
Object.defineProperty(exports, "_filterNullishValues", { enumerable: true, get: function () { return object_util_1._filterNullishValues; } });
|
|
116
|
-
Object.defineProperty(exports, "_filterObject", { enumerable: true, get: function () { return object_util_1._filterObject; } });
|
|
117
|
-
Object.defineProperty(exports, "_filterUndefinedValues", { enumerable: true, get: function () { return object_util_1._filterUndefinedValues; } });
|
|
118
|
-
Object.defineProperty(exports, "_findKeyByValue", { enumerable: true, get: function () { return object_util_1._findKeyByValue; } });
|
|
119
|
-
Object.defineProperty(exports, "_get", { enumerable: true, get: function () { return object_util_1._get; } });
|
|
120
|
-
Object.defineProperty(exports, "_has", { enumerable: true, get: function () { return object_util_1._has; } });
|
|
121
|
-
Object.defineProperty(exports, "_invert", { enumerable: true, get: function () { return object_util_1._invert; } });
|
|
122
|
-
Object.defineProperty(exports, "_invertMap", { enumerable: true, get: function () { return object_util_1._invertMap; } });
|
|
123
|
-
Object.defineProperty(exports, "_isEmpty", { enumerable: true, get: function () { return object_util_1._isEmpty; } });
|
|
124
|
-
Object.defineProperty(exports, "_isEmptyObject", { enumerable: true, get: function () { return object_util_1._isEmptyObject; } });
|
|
125
|
-
Object.defineProperty(exports, "_isObject", { enumerable: true, get: function () { return object_util_1._isObject; } });
|
|
126
|
-
Object.defineProperty(exports, "_isPrimitive", { enumerable: true, get: function () { return object_util_1._isPrimitive; } });
|
|
127
|
-
Object.defineProperty(exports, "_mapKeys", { enumerable: true, get: function () { return object_util_1._mapKeys; } });
|
|
128
|
-
Object.defineProperty(exports, "_mapObject", { enumerable: true, get: function () { return object_util_1._mapObject; } });
|
|
129
|
-
Object.defineProperty(exports, "_mapValues", { enumerable: true, get: function () { return object_util_1._mapValues; } });
|
|
130
|
-
Object.defineProperty(exports, "_mask", { enumerable: true, get: function () { return object_util_1._mask; } });
|
|
131
|
-
Object.defineProperty(exports, "_merge", { enumerable: true, get: function () { return object_util_1._merge; } });
|
|
132
|
-
Object.defineProperty(exports, "_objectNullValuesToUndefined", { enumerable: true, get: function () { return object_util_1._objectNullValuesToUndefined; } });
|
|
133
|
-
Object.defineProperty(exports, "_omit", { enumerable: true, get: function () { return object_util_1._omit; } });
|
|
134
|
-
Object.defineProperty(exports, "_pick", { enumerable: true, get: function () { return object_util_1._pick; } });
|
|
135
|
-
Object.defineProperty(exports, "_set", { enumerable: true, get: function () { return object_util_1._set; } });
|
|
136
|
-
Object.defineProperty(exports, "_undefinedIfEmpty", { enumerable: true, get: function () { return object_util_1._undefinedIfEmpty; } });
|
|
137
|
-
Object.defineProperty(exports, "_unset", { enumerable: true, get: function () { return object_util_1._unset; } });
|
|
138
|
-
const sortObject_1 = require("./object/sortObject");
|
|
139
|
-
Object.defineProperty(exports, "_sortObject", { enumerable: true, get: function () { return sortObject_1._sortObject; } });
|
|
140
|
-
const sortObjectDeep_1 = require("./object/sortObjectDeep");
|
|
141
|
-
Object.defineProperty(exports, "_sortObjectDeep", { enumerable: true, get: function () { return sortObjectDeep_1._sortObjectDeep; } });
|
|
61
|
+
(0, tslib_1.__exportStar)(require("./math/math.util"), exports);
|
|
62
|
+
(0, tslib_1.__exportStar)(require("./math/sma"), exports);
|
|
63
|
+
(0, tslib_1.__exportStar)(require("./number/createDeterministicRandom"), exports);
|
|
64
|
+
(0, tslib_1.__exportStar)(require("./number/number.util"), exports);
|
|
65
|
+
(0, tslib_1.__exportStar)(require("./object/deepEquals"), exports);
|
|
66
|
+
(0, tslib_1.__exportStar)(require("./object/object.util"), exports);
|
|
67
|
+
(0, tslib_1.__exportStar)(require("./object/sortObject"), exports);
|
|
68
|
+
(0, tslib_1.__exportStar)(require("./object/sortObjectDeep"), exports);
|
|
142
69
|
const AggregatedError_1 = require("./promise/AggregatedError");
|
|
143
70
|
Object.defineProperty(exports, "AggregatedError", { enumerable: true, get: function () { return AggregatedError_1.AggregatedError; } });
|
|
144
|
-
|
|
145
|
-
Object.defineProperty(exports, "pBatch", { enumerable: true, get: function () { return pBatch_1.pBatch; } });
|
|
71
|
+
(0, tslib_1.__exportStar)(require("./promise/pBatch"), exports);
|
|
146
72
|
const pDefer_1 = require("./promise/pDefer");
|
|
147
73
|
Object.defineProperty(exports, "pDefer", { enumerable: true, get: function () { return pDefer_1.pDefer; } });
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
Object.defineProperty(exports, "pFilter", { enumerable: true, get: function () { return pFilter_1.pFilter; } });
|
|
152
|
-
const pHang_1 = require("./promise/pHang");
|
|
153
|
-
Object.defineProperty(exports, "pHang", { enumerable: true, get: function () { return pHang_1.pHang; } });
|
|
74
|
+
(0, tslib_1.__exportStar)(require("./promise/pDelay"), exports);
|
|
75
|
+
(0, tslib_1.__exportStar)(require("./promise/pFilter"), exports);
|
|
76
|
+
(0, tslib_1.__exportStar)(require("./promise/pHang"), exports);
|
|
154
77
|
const pMap_1 = require("./promise/pMap");
|
|
155
78
|
Object.defineProperty(exports, "pMap", { enumerable: true, get: function () { return pMap_1.pMap; } });
|
|
156
|
-
|
|
157
|
-
Object.defineProperty(exports, "pProps", { enumerable: true, get: function () { return pProps_1.pProps; } });
|
|
79
|
+
(0, tslib_1.__exportStar)(require("./promise/pProps"), exports);
|
|
158
80
|
const pRetry_1 = require("./promise/pRetry");
|
|
159
81
|
Object.defineProperty(exports, "pRetry", { enumerable: true, get: function () { return pRetry_1.pRetry; } });
|
|
160
|
-
|
|
161
|
-
Object.defineProperty(exports, "pState", { enumerable: true, get: function () { return pState_1.pState; } });
|
|
82
|
+
(0, tslib_1.__exportStar)(require("./promise/pState"), exports);
|
|
162
83
|
const pTimeout_1 = require("./promise/pTimeout");
|
|
163
84
|
Object.defineProperty(exports, "pTimeout", { enumerable: true, get: function () { return pTimeout_1.pTimeout; } });
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
Object.defineProperty(exports, "_kebabCase", { enumerable: true, get: function () { return case_1._kebabCase; } });
|
|
169
|
-
Object.defineProperty(exports, "_snakeCase", { enumerable: true, get: function () { return case_1._snakeCase; } });
|
|
170
|
-
const json_util_1 = require("./string/json.util");
|
|
171
|
-
Object.defineProperty(exports, "_jsonParseIfPossible", { enumerable: true, get: function () { return json_util_1._jsonParseIfPossible; } });
|
|
172
|
-
const string_util_1 = require("./string/string.util");
|
|
173
|
-
Object.defineProperty(exports, "_capitalize", { enumerable: true, get: function () { return string_util_1._capitalize; } });
|
|
174
|
-
Object.defineProperty(exports, "_lowerFirst", { enumerable: true, get: function () { return string_util_1._lowerFirst; } });
|
|
175
|
-
Object.defineProperty(exports, "_nl2br", { enumerable: true, get: function () { return string_util_1._nl2br; } });
|
|
176
|
-
Object.defineProperty(exports, "_removeWhitespace", { enumerable: true, get: function () { return string_util_1._removeWhitespace; } });
|
|
177
|
-
Object.defineProperty(exports, "_replaceAll", { enumerable: true, get: function () { return string_util_1._replaceAll; } });
|
|
178
|
-
Object.defineProperty(exports, "_split", { enumerable: true, get: function () { return string_util_1._split; } });
|
|
179
|
-
Object.defineProperty(exports, "_substringAfter", { enumerable: true, get: function () { return string_util_1._substringAfter; } });
|
|
180
|
-
Object.defineProperty(exports, "_substringAfterLast", { enumerable: true, get: function () { return string_util_1._substringAfterLast; } });
|
|
181
|
-
Object.defineProperty(exports, "_substringBefore", { enumerable: true, get: function () { return string_util_1._substringBefore; } });
|
|
182
|
-
Object.defineProperty(exports, "_substringBeforeLast", { enumerable: true, get: function () { return string_util_1._substringBeforeLast; } });
|
|
183
|
-
Object.defineProperty(exports, "_substringBetweenLast", { enumerable: true, get: function () { return string_util_1._substringBetweenLast; } });
|
|
184
|
-
Object.defineProperty(exports, "_truncate", { enumerable: true, get: function () { return string_util_1._truncate; } });
|
|
185
|
-
Object.defineProperty(exports, "_truncateMiddle", { enumerable: true, get: function () { return string_util_1._truncateMiddle; } });
|
|
186
|
-
Object.defineProperty(exports, "_upperFirst", { enumerable: true, get: function () { return string_util_1._upperFirst; } });
|
|
85
|
+
(0, tslib_1.__exportStar)(require("./promise/pTuple"), exports);
|
|
86
|
+
(0, tslib_1.__exportStar)(require("./string/case"), exports);
|
|
87
|
+
(0, tslib_1.__exportStar)(require("./string/json.util"), exports);
|
|
88
|
+
(0, tslib_1.__exportStar)(require("./string/string.util"), exports);
|
|
187
89
|
const stringifyAny_1 = require("./string/stringifyAny");
|
|
188
90
|
Object.defineProperty(exports, "_stringifyAny", { enumerable: true, get: function () { return stringifyAny_1._stringifyAny; } });
|
|
189
91
|
const time_util_1 = require("./time/time.util");
|
|
190
92
|
Object.defineProperty(exports, "_ms", { enumerable: true, get: function () { return time_util_1._ms; } });
|
|
191
93
|
Object.defineProperty(exports, "_since", { enumerable: true, get: function () { return time_util_1._since; } });
|
|
192
94
|
const types_1 = require("./types");
|
|
95
|
+
Object.defineProperty(exports, "END", { enumerable: true, get: function () { return types_1.END; } });
|
|
96
|
+
Object.defineProperty(exports, "SKIP", { enumerable: true, get: function () { return types_1.SKIP; } });
|
|
193
97
|
Object.defineProperty(exports, "_noop", { enumerable: true, get: function () { return types_1._noop; } });
|
|
194
98
|
Object.defineProperty(exports, "_objectKeys", { enumerable: true, get: function () { return types_1._objectKeys; } });
|
|
195
99
|
Object.defineProperty(exports, "_passNothingPredicate", { enumerable: true, get: function () { return types_1._passNothingPredicate; } });
|
|
@@ -216,3 +120,5 @@ const safeJsonStringify_1 = require("./string/safeJsonStringify");
|
|
|
216
120
|
Object.defineProperty(exports, "_safeJsonStringify", { enumerable: true, get: function () { return safeJsonStringify_1._safeJsonStringify; } });
|
|
217
121
|
const pQueue_1 = require("./promise/pQueue");
|
|
218
122
|
Object.defineProperty(exports, "PQueue", { enumerable: true, get: function () { return pQueue_1.PQueue; } });
|
|
123
|
+
(0, tslib_1.__exportStar)(require("./seq/seq"), exports);
|
|
124
|
+
(0, tslib_1.__exportStar)(require("./math/stack.util"), exports);
|
package/dist/math/sma.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Implements a Simple Moving Average algorithm.
|
|
3
3
|
*/
|
|
4
4
|
export declare class SimpleMovingAverage {
|
|
5
|
-
size: number;
|
|
6
|
-
data: number[];
|
|
5
|
+
readonly size: number;
|
|
6
|
+
readonly data: number[];
|
|
7
7
|
constructor(size: number, data?: number[]);
|
|
8
8
|
/**
|
|
9
9
|
* Next index of array to push to
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements a "round-robin" Stack with a limited size.
|
|
3
|
+
* Like an array of a fixed size. When it runs out of space - it starts writing on top of itself
|
|
4
|
+
* from index 0.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SizeLimitedStack<T> {
|
|
7
|
+
readonly size: number;
|
|
8
|
+
constructor(size: number);
|
|
9
|
+
/**
|
|
10
|
+
* Index of a slot to get written TO next.
|
|
11
|
+
* Currently this slot contains OLDEST item (if any).
|
|
12
|
+
*/
|
|
13
|
+
private nextIndex;
|
|
14
|
+
readonly items: T[];
|
|
15
|
+
push(item: T): void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns last items in the right order.
|
|
18
|
+
* Unlike raw `items` property that returns "items buffer" as-is (not ordered properly).
|
|
19
|
+
*/
|
|
20
|
+
get itemsOrdered(): T[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SizeLimitedStack = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Implements a "round-robin" Stack with a limited size.
|
|
6
|
+
* Like an array of a fixed size. When it runs out of space - it starts writing on top of itself
|
|
7
|
+
* from index 0.
|
|
8
|
+
*/
|
|
9
|
+
class SizeLimitedStack {
|
|
10
|
+
constructor(size) {
|
|
11
|
+
this.size = size;
|
|
12
|
+
/**
|
|
13
|
+
* Index of a slot to get written TO next.
|
|
14
|
+
* Currently this slot contains OLDEST item (if any).
|
|
15
|
+
*/
|
|
16
|
+
this.nextIndex = 0;
|
|
17
|
+
this.items = [];
|
|
18
|
+
}
|
|
19
|
+
push(item) {
|
|
20
|
+
this.items[this.nextIndex] = item;
|
|
21
|
+
this.nextIndex = this.nextIndex === this.size - 1 ? 0 : this.nextIndex + 1;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns last items in the right order.
|
|
25
|
+
* Unlike raw `items` property that returns "items buffer" as-is (not ordered properly).
|
|
26
|
+
*/
|
|
27
|
+
get itemsOrdered() {
|
|
28
|
+
if (this.items.length < this.size) {
|
|
29
|
+
// Buffer is not filled yet, just return it as-is
|
|
30
|
+
return this.items;
|
|
31
|
+
}
|
|
32
|
+
// Buffer was filled and started to "overwrite itself", will need to return 2 slices
|
|
33
|
+
return [...this.items.slice(this.nextIndex), ...this.items.slice(0, this.nextIndex)];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.SizeLimitedStack = SizeLimitedStack;
|
package/dist/promise/pBatch.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { BatchResult } from '..';
|
|
2
|
-
import { AsyncMapper } from '../types';
|
|
1
|
+
import { AbortableAsyncMapper, BatchResult } from '..';
|
|
3
2
|
/**
|
|
4
3
|
* Like pMap, but doesn't fail on errors, instead returns both successful results and errors.
|
|
5
4
|
*/
|
|
6
|
-
export declare function pBatch<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper:
|
|
5
|
+
export declare function pBatch<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AbortableAsyncMapper<IN, OUT>, opt?: {
|
|
7
6
|
concurrency?: number;
|
|
8
7
|
}): Promise<BatchResult<OUT>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbortableAsyncPredicate } from '../types';
|
|
2
2
|
import { PMapOptions } from './pMap';
|
|
3
|
-
export declare function pFilter<T>(iterable: Iterable<T | PromiseLike<T>>, filterFn:
|
|
3
|
+
export declare function pFilter<T>(iterable: Iterable<T | PromiseLike<T>>, filterFn: AbortableAsyncPredicate<T>, opt?: PMapOptions): Promise<T[]>;
|
package/dist/promise/pMap.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ErrorMode } from '..';
|
|
2
|
-
import { AsyncMapper } from '../types';
|
|
1
|
+
import { AbortableAsyncMapper, ErrorMode } from '..';
|
|
3
2
|
export interface PMapOptions {
|
|
4
3
|
/**
|
|
5
4
|
* Number of concurrently pending promises returned by `mapper`.
|
|
@@ -42,4 +41,4 @@ export interface PMapOptions {
|
|
|
42
41
|
* //=> ['http://ava.li/', 'http://todomvc.com/']
|
|
43
42
|
* })();
|
|
44
43
|
*/
|
|
45
|
-
export declare function pMap<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper:
|
|
44
|
+
export declare function pMap<IN, OUT>(iterable: Iterable<IN | PromiseLike<IN>>, mapper: AbortableAsyncMapper<IN, OUT>, opt?: PMapOptions): Promise<OUT[]>;
|
package/dist/promise/pMap.js
CHANGED
|
@@ -43,25 +43,27 @@ async function pMap(iterable, mapper, opt = {}) {
|
|
|
43
43
|
const ret = [];
|
|
44
44
|
const iterator = iterable[Symbol.iterator]();
|
|
45
45
|
const errors = [];
|
|
46
|
-
let
|
|
46
|
+
let isSettled = false;
|
|
47
47
|
let isIterableDone = false;
|
|
48
48
|
let resolvingCount = 0;
|
|
49
49
|
let currentIndex = 0;
|
|
50
|
-
const next = () => {
|
|
51
|
-
if (
|
|
50
|
+
const next = (skipped = false) => {
|
|
51
|
+
if (isSettled) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
const nextItem = iterator.next();
|
|
55
55
|
const i = currentIndex;
|
|
56
|
-
|
|
56
|
+
if (!skipped)
|
|
57
|
+
currentIndex++;
|
|
57
58
|
if (nextItem.done) {
|
|
58
59
|
isIterableDone = true;
|
|
59
60
|
if (resolvingCount === 0) {
|
|
61
|
+
const r = ret.filter(r => r !== __1.SKIP);
|
|
60
62
|
if (errors.length && errorMode === __1.ErrorMode.THROW_AGGREGATED) {
|
|
61
|
-
reject(new AggregatedError_1.AggregatedError(errors,
|
|
63
|
+
reject(new AggregatedError_1.AggregatedError(errors, r));
|
|
62
64
|
}
|
|
63
65
|
else {
|
|
64
|
-
resolve(
|
|
66
|
+
resolve(r);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
return;
|
|
@@ -70,12 +72,16 @@ async function pMap(iterable, mapper, opt = {}) {
|
|
|
70
72
|
Promise.resolve(nextItem.value)
|
|
71
73
|
.then(async (element) => await mapper(element, i))
|
|
72
74
|
.then(value => {
|
|
75
|
+
if (value === __1.END) {
|
|
76
|
+
isSettled = true;
|
|
77
|
+
return resolve(ret.filter(r => r !== __1.SKIP));
|
|
78
|
+
}
|
|
73
79
|
ret[i] = value;
|
|
74
80
|
resolvingCount--;
|
|
75
81
|
next();
|
|
76
82
|
}, err => {
|
|
77
83
|
if (errorMode === __1.ErrorMode.THROW_IMMEDIATELY) {
|
|
78
|
-
|
|
84
|
+
isSettled = true;
|
|
79
85
|
reject(err);
|
|
80
86
|
}
|
|
81
87
|
else {
|
package/dist/promise/pProps.d.ts
CHANGED
package/dist/promise/pProps.js
CHANGED
|
@@ -11,17 +11,16 @@ Improvements:
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.pProps = void 0;
|
|
13
13
|
const pMap_1 = require("./pMap");
|
|
14
|
+
// todo: remove when eslint starts to know about Awaited
|
|
15
|
+
/* eslint-disable no-undef */
|
|
14
16
|
/**
|
|
15
17
|
* Promise.all for Object instead of Array.
|
|
16
18
|
* Supports concurrency.
|
|
17
19
|
*/
|
|
18
20
|
async function pProps(input, opt) {
|
|
19
|
-
const keys = Object.keys(input);
|
|
20
|
-
const values = await (0, pMap_1.pMap)(Object.values(input), r => r, opt);
|
|
21
21
|
const r = {};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
22
|
+
const keys = Object.keys(input);
|
|
23
|
+
await (0, pMap_1.pMap)(Object.values(input), (v, i) => (r[keys[i]] = v), opt);
|
|
25
24
|
return r;
|
|
26
25
|
}
|
|
27
26
|
exports.pProps = pProps;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbortableMapper, AbortablePredicate, END } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Inspired by Kotlin Sequences.
|
|
4
|
+
* Similar to arrays, but with lazy evaluation, abortable.
|
|
5
|
+
* Can be useful when it's not feasible/performant to create an array of values to iterate upfront
|
|
6
|
+
* (e.g to construct 1000 Dayjs instances only to find that 2 of them were needed).
|
|
7
|
+
*
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export declare class Seq<T> implements Iterable<T> {
|
|
11
|
+
private nextFn;
|
|
12
|
+
private constructor();
|
|
13
|
+
[Symbol.iterator](): Iterator<T>;
|
|
14
|
+
static create<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Seq<T>;
|
|
15
|
+
static range(minIncl: number, maxExcl: number, step?: number): Seq<number>;
|
|
16
|
+
static from<T>(a: Iterable<T>): Seq<T>;
|
|
17
|
+
static empty<T = any>(): Seq<T>;
|
|
18
|
+
private currentValue;
|
|
19
|
+
private sentInitialValue;
|
|
20
|
+
private i;
|
|
21
|
+
next(): T | typeof END;
|
|
22
|
+
find(predicate: AbortablePredicate<T>): T | undefined;
|
|
23
|
+
some(predicate: AbortablePredicate<T>): boolean;
|
|
24
|
+
every(predicate: AbortablePredicate<T>): boolean;
|
|
25
|
+
toArray(): T[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convenience function to create a Sequence.
|
|
29
|
+
*/
|
|
30
|
+
export declare function _seq<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Seq<T>;
|