@naturalcycles/js-lib 14.71.0 → 14.75.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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { _by, _chunk, _countBy, _difference, _dropRightWhile, _dropWhile, _findLast, _flatten, _flattenDeep, _groupBy, _intersection, _last, _mapToObject, _shuffle, _sortBy, _sum, _sumBy, _takeRightWhile, _takeWhile, _uniq, _uniqBy } from './array/array.util';
2
- import { _defineLazyProperty, _defineLazyProps, _lazyValue } from './lazy';
3
- import { _parseQueryString } from './string/url.util';
4
- import { _range } from './array/range';
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,29 +25,29 @@ 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
- import { _average, _averageWeighted, _median, _percentile } from './math/math.util';
29
- import { SimpleMovingAverage } from './math/sma';
30
- import { _createDeterministicRandom } from './number/createDeterministicRandom';
31
- import { _clamp, _inRange, _randomInt, _randomArrayItem, _round, _sortNumbers, _toFixed, _toPrecision } from './number/number.util';
32
- import { _deepEquals } from './object/deepEquals';
33
- import { _deepCopy, _deepTrim, _filterEmptyArrays, _filterEmptyValues, _filterFalsyValues, _filterNullishValues, _filterObject, _filterUndefinedValues, _findKeyByValue, _get, _has, _invert, _invertMap, _isEmpty, _isEmptyObject, _isObject, _isPrimitive, _mapKeys, _mapObject, _mapValues, _mask, _merge, _objectNullValuesToUndefined, _omit, _pick, _set, _undefinedIfEmpty, _unset } from './object/object.util';
34
- import { _sortObject } from './object/sortObject';
35
- import { _sortObjectDeep } from './object/sortObjectDeep';
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
- import { pBatch } from './promise/pBatch';
37
+ export * from './promise/pBatch';
38
38
  import { DeferredPromise, pDefer } from './promise/pDefer';
39
- import { pDelay } from './promise/pDelay';
40
- import { pFilter } from './promise/pFilter';
41
- import { pHang } from './promise/pHang';
39
+ export * from './promise/pDelay';
40
+ export * from './promise/pFilter';
41
+ export * from './promise/pHang';
42
42
  import { pMap, PMapOptions } from './promise/pMap';
43
- import { pProps } from './promise/pProps';
43
+ export * from './promise/pProps';
44
44
  import { pRetry, PRetryOptions } from './promise/pRetry';
45
- import { pState } from './promise/pState';
45
+ export * from './promise/pState';
46
46
  import { pTimeout, PTimeoutOptions } from './promise/pTimeout';
47
- import { pTuple } from './promise/pTuple';
48
- import { _camelCase, _kebabCase, _snakeCase } from './string/case';
49
- import { _jsonParseIfPossible } from './string/json.util';
50
- import { _capitalize, _lowerFirst, _nl2br, _removeWhitespace, _replaceAll, _split, _substringAfter, _substringAfterLast, _substringBefore, _substringBeforeLast, _substringBetweenLast, _truncate, _truncateMiddle, _upperFirst } from './string/string.util';
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
53
  import { Class, ConditionalExcept, ConditionalPick, Merge, Promisable, ReadonlyDeep, Simplify } from './typeFest';
@@ -58,5 +58,6 @@ import { CommonLogLevel, CommonLogFunction, CommonLogger, commonLoggerMinLevel,
58
58
  import { _safeJsonStringify } from './string/safeJsonStringify';
59
59
  import { PQueue, PQueueCfg } from './promise/pQueue';
60
60
  export * from './seq/seq';
61
+ export * from './math/stack.util';
61
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, };
62
- export { is, _Memo, _memoFn, _LogMethod, _getArgsSignature, _createPromiseDecorator, AppError, HttpError, AssertionError, _assert, _assertEquals, _assertDeepEquals, _assertIsError, _assertIsString, _assertIsNumber, _assertTypeOf, _randomInt, _randomArrayItem, _createDeterministicRandom, _inRange, _stringMapValues, _stringMapEntries, _objectKeys, _capitalize, _upperFirst, _lowerFirst, _split, _removeWhitespace, _substringBefore, _substringBeforeLast, _substringAfter, _substringAfterLast, _substringBetweenLast, _replaceAll, _nl2br, _truncate, _truncateMiddle, _pick, _omit, _filterFalsyValues, _filterUndefinedValues, _filterNullishValues, _filterEmptyArrays, _filterEmptyValues, _filterObject, _undefinedIfEmpty, _isObject, _isPrimitive, _mapKeys, _mapValues, _mapObject, _objectNullValuesToUndefined, _deepEquals, _deepCopy, _isEmptyObject, _isEmpty, _merge, _deepTrim, _sortObjectDeep, _sortObject, _get, _set, _has, _unset, _mask, _invert, _invertMap, _by, _groupBy, _sortBy, _sortNumbers, _toFixed, _toPrecision, _round, _findLast, _takeWhile, _takeRightWhile, _dropWhile, _dropRightWhile, _countBy, _intersection, _difference, _shuffle, _mapToObject, _findKeyByValue, _range, _uniq, _uniqBy, _flatten, _flattenDeep, _chunk, SimpleMovingAverage, _average, _averageWeighted, _percentile, _median, _debounce, _throttle, _Debounce, _Throttle, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, pBatch, ErrorMode, pFilter, pProps, pDelay, pDefer, pHang, pState, AggregatedError, pRetry, pTimeout, pTuple, _Retry, _Timeout, _tryCatch, _TryCatch, _try, pTry, _jsonParseIfPossible, _stringifyAny, _ms, _since, _hb, _gb, _mb, _kb, _snakeCase, _camelCase, _kebabCase, _sum, _sumBy, _clamp, _last, mergeJsonSchemaObjects, jsonSchema, JsonSchemaAnyBuilder, JSON_SCHEMA_ORDER, generateJsonSchemaFromData, _parseQueryString, _defineLazyProperty, _defineLazyProps, _lazyValue, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, _safeJsonStringify, PQueue, END, SKIP, };
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._mapValues = exports._mapKeys = exports._isPrimitive = exports._isObject = exports._undefinedIfEmpty = exports._filterObject = exports._filterEmptyValues = exports._filterEmptyArrays = exports._filterNullishValues = exports._filterUndefinedValues = exports._filterFalsyValues = exports._omit = exports._pick = exports._truncateMiddle = exports._truncate = exports._nl2br = exports._replaceAll = exports._substringBetweenLast = exports._substringAfterLast = exports._substringAfter = exports._substringBeforeLast = exports._substringBefore = exports._removeWhitespace = exports._split = exports._lowerFirst = exports._upperFirst = exports._capitalize = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._inRange = exports._createDeterministicRandom = exports._randomArrayItem = exports._randomInt = 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._Throttle = exports._Debounce = exports._throttle = exports._debounce = exports._median = exports._percentile = exports._averageWeighted = exports._average = exports.SimpleMovingAverage = exports._chunk = exports._flattenDeep = exports._flatten = exports._uniqBy = exports._uniq = exports._range = exports._findKeyByValue = exports._mapToObject = exports._shuffle = exports._difference = exports._intersection = exports._countBy = exports._dropRightWhile = exports._dropWhile = exports._takeRightWhile = exports._takeWhile = exports._findLast = exports._round = exports._toPrecision = exports._toFixed = exports._sortNumbers = exports._sortBy = exports._groupBy = exports._by = exports._invertMap = exports._invert = exports._mask = exports._unset = exports._has = exports._set = exports._get = exports._sortObject = exports._sortObjectDeep = exports._deepTrim = exports._merge = exports._isEmpty = exports._isEmptyObject = exports._deepCopy = exports._deepEquals = exports._objectNullValuesToUndefined = exports._mapObject = void 0;
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.SKIP = exports.END = 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
- const array_util_1 = require("./array/array.util");
9
- Object.defineProperty(exports, "_by", { enumerable: true, get: function () { return array_util_1._by; } });
10
- Object.defineProperty(exports, "_chunk", { enumerable: true, get: function () { return array_util_1._chunk; } });
11
- Object.defineProperty(exports, "_countBy", { enumerable: true, get: function () { return array_util_1._countBy; } });
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,104 +58,34 @@ 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
- const math_util_1 = require("./math/math.util");
90
- Object.defineProperty(exports, "_average", { enumerable: true, get: function () { return math_util_1._average; } });
91
- Object.defineProperty(exports, "_averageWeighted", { enumerable: true, get: function () { return math_util_1._averageWeighted; } });
92
- Object.defineProperty(exports, "_median", { enumerable: true, get: function () { return math_util_1._median; } });
93
- Object.defineProperty(exports, "_percentile", { enumerable: true, get: function () { return math_util_1._percentile; } });
94
- const sma_1 = require("./math/sma");
95
- Object.defineProperty(exports, "SimpleMovingAverage", { enumerable: true, get: function () { return sma_1.SimpleMovingAverage; } });
96
- const createDeterministicRandom_1 = require("./number/createDeterministicRandom");
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
- const pBatch_1 = require("./promise/pBatch");
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
- const pDelay_1 = require("./promise/pDelay");
149
- Object.defineProperty(exports, "pDelay", { enumerable: true, get: function () { return pDelay_1.pDelay; } });
150
- const pFilter_1 = require("./promise/pFilter");
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
- const pProps_1 = require("./promise/pProps");
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
- const pState_1 = require("./promise/pState");
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
- const pTuple_1 = require("./promise/pTuple");
165
- Object.defineProperty(exports, "pTuple", { enumerable: true, get: function () { return pTuple_1.pTuple; } });
166
- const case_1 = require("./string/case");
167
- Object.defineProperty(exports, "_camelCase", { enumerable: true, get: function () { return case_1._camelCase; } });
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");
@@ -219,3 +121,4 @@ Object.defineProperty(exports, "_safeJsonStringify", { enumerable: true, get: fu
219
121
  const pQueue_1 = require("./promise/pQueue");
220
122
  Object.defineProperty(exports, "PQueue", { enumerable: true, get: function () { return pQueue_1.PQueue; } });
221
123
  (0, tslib_1.__exportStar)(require("./seq/seq"), exports);
124
+ (0, tslib_1.__exportStar)(require("./math/stack.util"), exports);
@@ -24,6 +24,10 @@ export declare function _averageWeighted(values: number[], weights: number[]): n
24
24
  * // 3
25
25
  */
26
26
  export declare function _percentile(values: number[], pc: number): number;
27
+ /**
28
+ * A tiny bit more efficient function than calling _percentile individually.
29
+ */
30
+ export declare function _percentiles(values: number[], pcs: number[]): Record<number, number>;
27
31
  /**
28
32
  * @example
29
33
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._median = exports._percentile = exports._averageWeighted = exports._average = void 0;
3
+ exports._median = exports._percentiles = exports._percentile = exports._averageWeighted = exports._average = void 0;
4
4
  const number_util_1 = require("../number/number.util");
5
5
  /**
6
6
  * @returns Average of the array of numbers
@@ -45,6 +45,23 @@ function _percentile(values, pc) {
45
45
  return _averageWeighted([sorted[floorPos], sorted[ceilPos]], [1 - dec, dec]);
46
46
  }
47
47
  exports._percentile = _percentile;
48
+ /**
49
+ * A tiny bit more efficient function than calling _percentile individually.
50
+ */
51
+ function _percentiles(values, pcs) {
52
+ const r = {};
53
+ const sorted = (0, number_util_1._sortNumbers)(values);
54
+ pcs.forEach(pc => {
55
+ // Floating pos in the range of [0; length - 1]
56
+ const pos = ((values.length - 1) * pc) / 100;
57
+ const dec = pos % 1;
58
+ const floorPos = Math.floor(pos);
59
+ const ceilPos = Math.ceil(pos);
60
+ r[pc] = _averageWeighted([sorted[floorPos], sorted[ceilPos]], [1 - dec, dec]);
61
+ });
62
+ return r;
63
+ }
64
+ exports._percentiles = _percentiles;
48
65
  /**
49
66
  * @example
50
67
  *
@@ -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,50 @@
1
+ /**
2
+ * Implements a "round-robin" Stack ("first-in last-out" aka FILO) 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
+ *
7
+ */
8
+ export declare class Stack<T> {
9
+ readonly size: number;
10
+ constructor(size: number);
11
+ /**
12
+ * Index of a slot to get written TO next.
13
+ * Currently this slot contains OLDEST item (if any).
14
+ */
15
+ private nextIndex;
16
+ readonly items: T[];
17
+ push(item: T): this;
18
+ /**
19
+ * Fill (overwrite) the whole Stack (all its items) with the passed `item`.
20
+ */
21
+ fill(item: T): this;
22
+ /**
23
+ * Returns last items in the right order.
24
+ * Unlike raw `items` property that returns "items buffer" as-is (not ordered properly).
25
+ */
26
+ get itemsOrdered(): T[];
27
+ }
28
+ /**
29
+ * Fixed-size FILO stack of Numbers.
30
+ * Has convenience stat methods, e.g percentile, avg, etc.
31
+ */
32
+ export declare class NumberStack extends Stack<number> {
33
+ avg(): number;
34
+ /**
35
+ * Returns null if Stack is empty.
36
+ */
37
+ avgOrNull(): number | null;
38
+ median(): number;
39
+ medianOrNull(): number | null;
40
+ /**
41
+ * `pc` is a number from 0 to 100 inclusive.
42
+ */
43
+ percentile(pc: number): number;
44
+ /**
45
+ * `pc` is a number from 0 to 100 inclusive.
46
+ * Returns null if Stack is empty.
47
+ */
48
+ percentileOrNull(pc: number): number | null;
49
+ percentiles(pcs: number[]): Record<number, number>;
50
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumberStack = exports.Stack = void 0;
4
+ const index_1 = require("../index");
5
+ /**
6
+ * Implements a "round-robin" Stack ("first-in last-out" aka FILO) with a limited size.
7
+ * Like an array of a fixed size. When it runs out of space - it starts writing on top of itself
8
+ * from index 0.
9
+ *
10
+ *
11
+ */
12
+ class Stack {
13
+ constructor(size) {
14
+ this.size = size;
15
+ /**
16
+ * Index of a slot to get written TO next.
17
+ * Currently this slot contains OLDEST item (if any).
18
+ */
19
+ this.nextIndex = 0;
20
+ this.items = [];
21
+ }
22
+ push(item) {
23
+ this.items[this.nextIndex] = item;
24
+ this.nextIndex = this.nextIndex === this.size - 1 ? 0 : this.nextIndex + 1;
25
+ return this;
26
+ }
27
+ /**
28
+ * Fill (overwrite) the whole Stack (all its items) with the passed `item`.
29
+ */
30
+ fill(item) {
31
+ (0, index_1._range)(this.size).forEach(i => (this.items[i] = item));
32
+ return this;
33
+ }
34
+ /**
35
+ * Returns last items in the right order.
36
+ * Unlike raw `items` property that returns "items buffer" as-is (not ordered properly).
37
+ */
38
+ get itemsOrdered() {
39
+ if (this.items.length < this.size) {
40
+ // Buffer is not filled yet, just return it as-is
41
+ return this.items;
42
+ }
43
+ // Buffer was filled and started to "overwrite itself", will need to return 2 slices
44
+ return [...this.items.slice(this.nextIndex), ...this.items.slice(0, this.nextIndex)];
45
+ }
46
+ }
47
+ exports.Stack = Stack;
48
+ /**
49
+ * Fixed-size FILO stack of Numbers.
50
+ * Has convenience stat methods, e.g percentile, avg, etc.
51
+ */
52
+ class NumberStack extends Stack {
53
+ avg() {
54
+ // _assert(this.items.length, 'NumberStack.avg cannot be called on empty stack')
55
+ return (0, index_1._average)(this.items);
56
+ }
57
+ /**
58
+ * Returns null if Stack is empty.
59
+ */
60
+ avgOrNull() {
61
+ return this.items.length === 0 ? null : (0, index_1._average)(this.items);
62
+ }
63
+ median() {
64
+ return (0, index_1._percentile)(this.items, 50);
65
+ }
66
+ medianOrNull() {
67
+ return this.items.length === 0 ? null : (0, index_1._percentile)(this.items, 50);
68
+ }
69
+ /**
70
+ * `pc` is a number from 0 to 100 inclusive.
71
+ */
72
+ percentile(pc) {
73
+ // _assert(this.items.length, 'NumberStack.percentile cannot be called on empty stack')
74
+ return (0, index_1._percentile)(this.items, pc);
75
+ }
76
+ /**
77
+ * `pc` is a number from 0 to 100 inclusive.
78
+ * Returns null if Stack is empty.
79
+ */
80
+ percentileOrNull(pc) {
81
+ return this.items.length === 0 ? null : (0, index_1._percentile)(this.items, pc);
82
+ }
83
+ percentiles(pcs) {
84
+ return (0, index_1._percentiles)(this.items, pcs);
85
+ }
86
+ }
87
+ exports.NumberStack = NumberStack;
@@ -44,7 +44,7 @@ export declare function _toFixed(n: number, fractionDigits: number): number;
44
44
  * _toPrecision(1634.56, 1)
45
45
  * // 2000
46
46
  *
47
- * _toPrecision(1234.56, 2)
47
+ * _toPrecision(1634.56, 2)
48
48
  * // 1600
49
49
  */
50
50
  export declare function _toPrecision(n: number, precision: number): number;
@@ -67,7 +67,7 @@ exports._toFixed = _toFixed;
67
67
  * _toPrecision(1634.56, 1)
68
68
  * // 2000
69
69
  *
70
- * _toPrecision(1234.56, 2)
70
+ * _toPrecision(1634.56, 2)
71
71
  * // 1600
72
72
  */
73
73
  function _toPrecision(n, precision) {
package/dist/seq/seq.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AbortableMapper, AbortablePredicate, END } from '../types';
1
+ import { AbortableAsyncMapper, AbortableAsyncPredicate, AbortableMapper, AbortablePredicate, END } from '../types';
2
2
  /**
3
3
  * Inspired by Kotlin Sequences.
4
4
  * Similar to arrays, but with lazy evaluation, abortable.
@@ -7,14 +7,14 @@ import { AbortableMapper, AbortablePredicate, END } from '../types';
7
7
  *
8
8
  * @experimental
9
9
  */
10
- export declare class Seq<T> implements Iterable<T> {
10
+ export declare class Sequence<T> implements Iterable<T> {
11
11
  private nextFn;
12
12
  private constructor();
13
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>;
14
+ static create<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Sequence<T>;
15
+ static range(minIncl: number, maxExcl: number, step?: number): Sequence<number>;
16
+ static from<T>(a: Iterable<T>): Sequence<T>;
17
+ static empty<T = any>(): Sequence<T>;
18
18
  private currentValue;
19
19
  private sentInitialValue;
20
20
  private i;
@@ -27,4 +27,26 @@ export declare class Seq<T> implements Iterable<T> {
27
27
  /**
28
28
  * Convenience function to create a Sequence.
29
29
  */
30
- export declare function _seq<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Seq<T>;
30
+ export declare function _seq<T>(initialValue: T | typeof END, nextFn: AbortableMapper<T, T>): Sequence<T>;
31
+ /**
32
+ * Experimental.
33
+ * Feasibility to be proven.
34
+ *
35
+ * @experimental
36
+ */
37
+ export declare class AsyncSequence<T> implements AsyncIterable<T> {
38
+ private nextFn;
39
+ private constructor();
40
+ [Symbol.asyncIterator](): AsyncIterator<T>;
41
+ static create<T>(initialValue: T | typeof END, nextFn: AbortableAsyncMapper<T, T>): AsyncSequence<T>;
42
+ static from<T>(a: AsyncIterable<T>): Promise<AsyncSequence<T>>;
43
+ static empty<T = any>(): AsyncSequence<T>;
44
+ private currentValue;
45
+ private sentInitialValue;
46
+ private i;
47
+ next(): Promise<T | typeof END>;
48
+ find(predicate: AbortableAsyncPredicate<T>): Promise<T | undefined>;
49
+ some(predicate: AbortableAsyncPredicate<T>): Promise<boolean>;
50
+ every(predicate: AbortableAsyncPredicate<T>): Promise<boolean>;
51
+ toArray(): Promise<T[]>;
52
+ }