@naturalcycles/js-lib 14.71.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/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);
@@ -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-esm/index.js 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 { _createPromiseDecorator, } from './decorators/createPromiseDecorator';
6
6
  import { _debounce, _throttle } from './decorators/debounce';
7
7
  import { _Debounce, _Throttle } from './decorators/debounce.decorator';
@@ -22,29 +22,29 @@ import { generateJsonSchemaFromData } from './json-schema/from-data/generateJson
22
22
  import { JSON_SCHEMA_ORDER } from './json-schema/jsonSchema.cnst';
23
23
  import { mergeJsonSchemaObjects } from './json-schema/jsonSchema.util';
24
24
  import { jsonSchema, JsonSchemaAnyBuilder, } from './json-schema/jsonSchemaBuilder';
25
- import { _average, _averageWeighted, _median, _percentile } from './math/math.util';
26
- import { SimpleMovingAverage } from './math/sma';
27
- import { _createDeterministicRandom } from './number/createDeterministicRandom';
28
- import { _clamp, _inRange, _randomInt, _randomArrayItem, _round, _sortNumbers, _toFixed, _toPrecision, } from './number/number.util';
29
- import { _deepEquals } from './object/deepEquals';
30
- 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';
31
- import { _sortObject } from './object/sortObject';
32
- import { _sortObjectDeep } from './object/sortObjectDeep';
25
+ export * from './math/math.util';
26
+ export * from './math/sma';
27
+ export * from './number/createDeterministicRandom';
28
+ export * from './number/number.util';
29
+ export * from './object/deepEquals';
30
+ export * from './object/object.util';
31
+ export * from './object/sortObject';
32
+ export * from './object/sortObjectDeep';
33
33
  import { AggregatedError } from './promise/AggregatedError';
34
- import { pBatch } from './promise/pBatch';
34
+ export * from './promise/pBatch';
35
35
  import { pDefer } from './promise/pDefer';
36
- import { pDelay } from './promise/pDelay';
37
- import { pFilter } from './promise/pFilter';
38
- import { pHang } from './promise/pHang';
36
+ export * from './promise/pDelay';
37
+ export * from './promise/pFilter';
38
+ export * from './promise/pHang';
39
39
  import { pMap } from './promise/pMap';
40
- import { pProps } from './promise/pProps';
40
+ export * from './promise/pProps';
41
41
  import { pRetry } from './promise/pRetry';
42
- import { pState } from './promise/pState';
42
+ export * from './promise/pState';
43
43
  import { pTimeout } from './promise/pTimeout';
44
- import { pTuple } from './promise/pTuple';
45
- import { _camelCase, _kebabCase, _snakeCase } from './string/case';
46
- import { _jsonParseIfPossible } from './string/json.util';
47
- import { _capitalize, _lowerFirst, _nl2br, _removeWhitespace, _replaceAll, _split, _substringAfter, _substringAfterLast, _substringBefore, _substringBeforeLast, _substringBetweenLast, _truncate, _truncateMiddle, _upperFirst, } from './string/string.util';
44
+ export * from './promise/pTuple';
45
+ export * from './string/case';
46
+ export * from './string/json.util';
47
+ export * from './string/string.util';
48
48
  import { _stringifyAny } from './string/stringifyAny';
49
49
  import { _ms, _since } from './time/time.util';
50
50
  import { END, SKIP, _noop, _objectKeys, _passNothingPredicate, _passthroughMapper, _passthroughPredicate, _passUndefinedMapper, _stringMapEntries, _stringMapValues, } from './types';
@@ -54,4 +54,5 @@ import { commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLog
54
54
  import { _safeJsonStringify } from './string/safeJsonStringify';
55
55
  import { PQueue } from './promise/pQueue';
56
56
  export * from './seq/seq';
57
- 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, };
57
+ export * from './math/stack.util';
58
+ 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, };
@@ -0,0 +1,32 @@
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 class SizeLimitedStack {
7
+ constructor(size) {
8
+ this.size = size;
9
+ /**
10
+ * Index of a slot to get written TO next.
11
+ * Currently this slot contains OLDEST item (if any).
12
+ */
13
+ this.nextIndex = 0;
14
+ this.items = [];
15
+ }
16
+ push(item) {
17
+ this.items[this.nextIndex] = item;
18
+ this.nextIndex = this.nextIndex === this.size - 1 ? 0 : this.nextIndex + 1;
19
+ }
20
+ /**
21
+ * Returns last items in the right order.
22
+ * Unlike raw `items` property that returns "items buffer" as-is (not ordered properly).
23
+ */
24
+ get itemsOrdered() {
25
+ if (this.items.length < this.size) {
26
+ // Buffer is not filled yet, just return it as-is
27
+ return this.items;
28
+ }
29
+ // Buffer was filled and started to "overwrite itself", will need to return 2 slices
30
+ return [...this.items.slice(this.nextIndex), ...this.items.slice(0, this.nextIndex)];
31
+ }
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.71.0",
3
+ "version": "14.72.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
package/src/index.ts CHANGED
@@ -1,29 +1,7 @@
1
- import {
2
- _by,
3
- _chunk,
4
- _countBy,
5
- _difference,
6
- _dropRightWhile,
7
- _dropWhile,
8
- _findLast,
9
- _flatten,
10
- _flattenDeep,
11
- _groupBy,
12
- _intersection,
13
- _last,
14
- _mapToObject,
15
- _shuffle,
16
- _sortBy,
17
- _sum,
18
- _sumBy,
19
- _takeRightWhile,
20
- _takeWhile,
21
- _uniq,
22
- _uniqBy,
23
- } from './array/array.util'
24
- import { _defineLazyProperty, _defineLazyProps, _lazyValue } from './lazy'
25
- import { _parseQueryString } from './string/url.util'
26
- 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'
27
5
  import {
28
6
  PromiseDecoratorCfg,
29
7
  PromiseDecoratorResp,
@@ -89,82 +67,29 @@ import {
89
67
  JsonSchemaAnyBuilder,
90
68
  JsonSchemaBuilder,
91
69
  } from './json-schema/jsonSchemaBuilder'
92
- import { _average, _averageWeighted, _median, _percentile } from './math/math.util'
93
- import { SimpleMovingAverage } from './math/sma'
94
- import { _createDeterministicRandom } from './number/createDeterministicRandom'
95
- import {
96
- _clamp,
97
- _inRange,
98
- _randomInt,
99
- _randomArrayItem,
100
- _round,
101
- _sortNumbers,
102
- _toFixed,
103
- _toPrecision,
104
- } from './number/number.util'
105
- import { _deepEquals } from './object/deepEquals'
106
- import {
107
- _deepCopy,
108
- _deepTrim,
109
- _filterEmptyArrays,
110
- _filterEmptyValues,
111
- _filterFalsyValues,
112
- _filterNullishValues,
113
- _filterObject,
114
- _filterUndefinedValues,
115
- _findKeyByValue,
116
- _get,
117
- _has,
118
- _invert,
119
- _invertMap,
120
- _isEmpty,
121
- _isEmptyObject,
122
- _isObject,
123
- _isPrimitive,
124
- _mapKeys,
125
- _mapObject,
126
- _mapValues,
127
- _mask,
128
- _merge,
129
- _objectNullValuesToUndefined,
130
- _omit,
131
- _pick,
132
- _set,
133
- _undefinedIfEmpty,
134
- _unset,
135
- } from './object/object.util'
136
- import { _sortObject } from './object/sortObject'
137
- import { _sortObjectDeep } from './object/sortObjectDeep'
70
+ export * from './math/math.util'
71
+ export * from './math/sma'
72
+ export * from './number/createDeterministicRandom'
73
+ export * from './number/number.util'
74
+ export * from './object/deepEquals'
75
+ export * from './object/object.util'
76
+ export * from './object/sortObject'
77
+ export * from './object/sortObjectDeep'
138
78
  import { AggregatedError } from './promise/AggregatedError'
139
- import { pBatch } from './promise/pBatch'
79
+ export * from './promise/pBatch'
140
80
  import { DeferredPromise, pDefer } from './promise/pDefer'
141
- import { pDelay } from './promise/pDelay'
142
- import { pFilter } from './promise/pFilter'
143
- import { pHang } from './promise/pHang'
81
+ export * from './promise/pDelay'
82
+ export * from './promise/pFilter'
83
+ export * from './promise/pHang'
144
84
  import { pMap, PMapOptions } from './promise/pMap'
145
- import { pProps } from './promise/pProps'
85
+ export * from './promise/pProps'
146
86
  import { pRetry, PRetryOptions } from './promise/pRetry'
147
- import { pState } from './promise/pState'
87
+ export * from './promise/pState'
148
88
  import { pTimeout, PTimeoutOptions } from './promise/pTimeout'
149
- import { pTuple } from './promise/pTuple'
150
- import { _camelCase, _kebabCase, _snakeCase } from './string/case'
151
- import { _jsonParseIfPossible } from './string/json.util'
152
- import {
153
- _capitalize,
154
- _lowerFirst,
155
- _nl2br,
156
- _removeWhitespace,
157
- _replaceAll,
158
- _split,
159
- _substringAfter,
160
- _substringAfterLast,
161
- _substringBefore,
162
- _substringBeforeLast,
163
- _substringBetweenLast,
164
- _truncate,
165
- _truncateMiddle,
166
- _upperFirst,
167
- } from './string/string.util'
89
+ export * from './promise/pTuple'
90
+ export * from './string/case'
91
+ export * from './string/json.util'
92
+ export * from './string/string.util'
168
93
  import { JsonStringifyFunction, StringifyAnyOptions, _stringifyAny } from './string/stringifyAny'
169
94
  import { _ms, _since } from './time/time.util'
170
95
  import {
@@ -236,6 +161,7 @@ import {
236
161
  import { _safeJsonStringify } from './string/safeJsonStringify'
237
162
  import { PQueue, PQueueCfg } from './promise/pQueue'
238
163
  export * from './seq/seq'
164
+ export * from './math/stack.util'
239
165
 
240
166
  export type {
241
167
  AbortableMapper,
@@ -334,86 +260,9 @@ export {
334
260
  _assertIsString,
335
261
  _assertIsNumber,
336
262
  _assertTypeOf,
337
- _randomInt,
338
- _randomArrayItem,
339
- _createDeterministicRandom,
340
- _inRange,
341
263
  _stringMapValues,
342
264
  _stringMapEntries,
343
265
  _objectKeys,
344
- _capitalize,
345
- _upperFirst,
346
- _lowerFirst,
347
- _split,
348
- _removeWhitespace,
349
- _substringBefore,
350
- _substringBeforeLast,
351
- _substringAfter,
352
- _substringAfterLast,
353
- _substringBetweenLast,
354
- _replaceAll,
355
- _nl2br,
356
- _truncate,
357
- _truncateMiddle,
358
- _pick,
359
- _omit,
360
- _filterFalsyValues,
361
- _filterUndefinedValues,
362
- _filterNullishValues,
363
- _filterEmptyArrays,
364
- _filterEmptyValues,
365
- _filterObject,
366
- _undefinedIfEmpty,
367
- _isObject,
368
- _isPrimitive,
369
- _mapKeys,
370
- _mapValues,
371
- _mapObject,
372
- _objectNullValuesToUndefined,
373
- _deepEquals,
374
- _deepCopy,
375
- _isEmptyObject,
376
- _isEmpty,
377
- _merge,
378
- _deepTrim,
379
- _sortObjectDeep,
380
- _sortObject,
381
- _get,
382
- _set,
383
- _has,
384
- _unset,
385
- _mask,
386
- _invert,
387
- _invertMap,
388
- _by,
389
- _groupBy,
390
- _sortBy,
391
- _sortNumbers,
392
- _toFixed,
393
- _toPrecision,
394
- _round,
395
- _findLast,
396
- _takeWhile,
397
- _takeRightWhile,
398
- _dropWhile,
399
- _dropRightWhile,
400
- _countBy,
401
- _intersection,
402
- _difference,
403
- _shuffle,
404
- _mapToObject,
405
- _findKeyByValue,
406
- _range,
407
- _uniq,
408
- _uniqBy,
409
- _flatten,
410
- _flattenDeep,
411
- _chunk,
412
- SimpleMovingAverage,
413
- _average,
414
- _averageWeighted,
415
- _percentile,
416
- _median,
417
266
  _debounce,
418
267
  _throttle,
419
268
  _Debounce,
@@ -424,25 +273,17 @@ export {
424
273
  _passthroughPredicate,
425
274
  _passNothingPredicate,
426
275
  _noop,
427
- pBatch,
428
276
  ErrorMode,
429
- pFilter,
430
- pProps,
431
- pDelay,
432
277
  pDefer,
433
- pHang,
434
- pState,
435
278
  AggregatedError,
436
279
  pRetry,
437
280
  pTimeout,
438
- pTuple,
439
281
  _Retry,
440
282
  _Timeout,
441
283
  _tryCatch,
442
284
  _TryCatch,
443
285
  _try,
444
286
  pTry,
445
- _jsonParseIfPossible,
446
287
  _stringifyAny,
447
288
  _ms,
448
289
  _since,
@@ -450,22 +291,11 @@ export {
450
291
  _gb,
451
292
  _mb,
452
293
  _kb,
453
- _snakeCase,
454
- _camelCase,
455
- _kebabCase,
456
- _sum,
457
- _sumBy,
458
- _clamp,
459
- _last,
460
294
  mergeJsonSchemaObjects,
461
295
  jsonSchema,
462
296
  JsonSchemaAnyBuilder,
463
297
  JSON_SCHEMA_ORDER,
464
298
  generateJsonSchemaFromData,
465
- _parseQueryString,
466
- _defineLazyProperty,
467
- _defineLazyProps,
468
- _lazyValue,
469
299
  commonLoggerMinLevel,
470
300
  commonLoggerNoop,
471
301
  commonLogLevelNumber,
package/src/math/sma.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Implements a Simple Moving Average algorithm.
3
3
  */
4
4
  export class SimpleMovingAverage {
5
- constructor(public size: number, public data: number[] = []) {}
5
+ constructor(public readonly size: number, public readonly data: number[] = []) {}
6
6
 
7
7
  /**
8
8
  * Next index of array to push to
@@ -0,0 +1,35 @@
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 class SizeLimitedStack<T> {
7
+ constructor(public readonly size: number) {}
8
+
9
+ /**
10
+ * Index of a slot to get written TO next.
11
+ * Currently this slot contains OLDEST item (if any).
12
+ */
13
+ private nextIndex = 0
14
+
15
+ readonly items: T[] = []
16
+
17
+ push(item: T): void {
18
+ this.items[this.nextIndex] = item
19
+ this.nextIndex = this.nextIndex === this.size - 1 ? 0 : this.nextIndex + 1
20
+ }
21
+
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
+ if (this.items.length < this.size) {
28
+ // Buffer is not filled yet, just return it as-is
29
+ return this.items
30
+ }
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
+ }