@naturalcycles/js-lib 14.86.0 → 14.89.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.
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localTime = exports.LocalTime = void 0;
4
+ const assert_1 = require("../error/assert");
5
+ /* eslint-disable no-dupe-class-members */
6
+ // Design choices:
7
+ // No milliseconds
8
+ // No timezone support, ISO8601 is parsed as LocalDateTime, discarding Timezone information
9
+ // Formats as unix timestamp, ISO8601 or "pretty string"
10
+ // toString and .toJSON formats as unix timestamp
11
+ // No "unixMillis", just pure unixtimestamp
12
+ // .valueOf returns unix timestamp (no millis)
13
+ // Prevents dayjs(undefined) being dayjs.now()
14
+ // Validates on parse, throws if invalid. Doesn't allow invalid objects
15
+ /**
16
+ * @experimental
17
+ */
18
+ class LocalTime {
19
+ constructor($date) {
20
+ this.$date = $date;
21
+ }
22
+ /**
23
+ * Parses input String into LocalDate.
24
+ * Input can already be a LocalDate - it is returned as-is in that case.
25
+ */
26
+ static of(d) {
27
+ if (d instanceof LocalTime)
28
+ return d;
29
+ if (d instanceof Date)
30
+ return new LocalTime(d);
31
+ if (typeof d === 'number') {
32
+ // unix timestamp
33
+ return new LocalTime(new Date(d * 1000));
34
+ }
35
+ const date = new Date(d);
36
+ // validation
37
+ if (isNaN(date.getDate())) {
38
+ throw new TypeError(`Cannot parse "${d}" into LocalTime`);
39
+ }
40
+ return new LocalTime(date);
41
+ }
42
+ static unix(ts) {
43
+ return new LocalTime(new Date(ts * 1000));
44
+ }
45
+ static now() {
46
+ return this.of(new Date());
47
+ }
48
+ static fromComponents(c) {
49
+ return new LocalTime(new Date(c.year, c.month - 1, c.day, c.hour, c.minute, c.second));
50
+ }
51
+ get(unit) {
52
+ if (unit === 'year') {
53
+ return this.$date.getFullYear();
54
+ }
55
+ if (unit === 'month') {
56
+ return this.$date.getMonth() + 1;
57
+ }
58
+ if (unit === 'day') {
59
+ return this.$date.getDate();
60
+ }
61
+ if (unit === 'hour') {
62
+ return this.$date.getHours();
63
+ }
64
+ if (unit === 'minute') {
65
+ return this.$date.getMinutes();
66
+ }
67
+ // second
68
+ return this.$date.getSeconds();
69
+ }
70
+ set(unit, v, mutate = false) {
71
+ const t = mutate ? this : this.clone();
72
+ if (unit === 'year') {
73
+ t.$date.setFullYear(v);
74
+ }
75
+ else if (unit === 'month') {
76
+ t.$date.setMonth(v - 1);
77
+ }
78
+ else if (unit === 'day') {
79
+ t.$date.setDate(v);
80
+ }
81
+ else if (unit === 'hour') {
82
+ t.$date.setHours(v);
83
+ }
84
+ else if (unit === 'minute') {
85
+ t.$date.setMinutes(v);
86
+ }
87
+ else if (unit === 'second') {
88
+ t.$date.setSeconds(v);
89
+ }
90
+ return t;
91
+ }
92
+ year(v) {
93
+ return v === undefined ? this.$date.getFullYear() : this.set('year', v);
94
+ }
95
+ month(v) {
96
+ return v === undefined ? this.$date.getMonth() + 1 : this.set('month', v);
97
+ }
98
+ date(v) {
99
+ return v === undefined ? this.$date.getDate() : this.set('day', v);
100
+ }
101
+ hour(v) {
102
+ return v === undefined ? this.$date.getHours() : this.set('hour', v);
103
+ }
104
+ minute(v) {
105
+ return v === undefined ? this.$date.getMinutes() : this.set('minute', v);
106
+ }
107
+ second(v) {
108
+ return v === undefined ? this.$date.getSeconds() : this.set('second', v);
109
+ }
110
+ setComponents(c, mutate = false) {
111
+ const d = mutate ? this.$date : new Date(this.$date);
112
+ if (c.year) {
113
+ d.setFullYear(c.year);
114
+ }
115
+ if (c.month) {
116
+ d.setMonth(c.month - 1);
117
+ }
118
+ if (c.day) {
119
+ d.setDate(c.day);
120
+ }
121
+ if (c.hour !== undefined) {
122
+ d.setHours(c.hour);
123
+ }
124
+ if (c.minute !== undefined) {
125
+ d.setMinutes(c.minute);
126
+ }
127
+ if (c.second !== undefined) {
128
+ d.setSeconds(c.second);
129
+ }
130
+ return mutate ? this : new LocalTime(d);
131
+ }
132
+ add(num, unit, mutate = false) {
133
+ return this.set(unit, this.get(unit) + num, mutate);
134
+ }
135
+ subtract(num, unit, mutate = false) {
136
+ return this.add(-num, unit, mutate);
137
+ }
138
+ absDiff(other, unit) {
139
+ return Math.abs(this.diff(other, unit));
140
+ }
141
+ diff(other, unit) {
142
+ const date2 = LocalTime.of(other).$date;
143
+ if (unit === 'year') {
144
+ return this.$date.getFullYear() - date2.getFullYear();
145
+ }
146
+ if (unit === 'month') {
147
+ return ((this.$date.getFullYear() - date2.getFullYear()) * 12 +
148
+ this.$date.getMonth() -
149
+ date2.getMonth());
150
+ }
151
+ const secDiff = (this.$date.valueOf() - date2.valueOf()) / 1000;
152
+ let r;
153
+ if (unit === 'day') {
154
+ r = secDiff / (24 * 60 * 60);
155
+ }
156
+ else if (unit === 'hour') {
157
+ r = secDiff / (60 * 60);
158
+ }
159
+ else if (unit === 'minute') {
160
+ r = secDiff / 60;
161
+ }
162
+ else {
163
+ // unit === 'second'
164
+ r = secDiff;
165
+ }
166
+ r = r < 0 ? -Math.floor(-r) : Math.floor(r);
167
+ if (Object.is(r, -0))
168
+ return 0;
169
+ return r;
170
+ }
171
+ startOf(unit, mutate = false) {
172
+ if (unit === 'second')
173
+ return this;
174
+ if (mutate) {
175
+ const d = this.$date;
176
+ d.setSeconds(0);
177
+ if (unit === 'minute')
178
+ return this;
179
+ d.setMinutes(0);
180
+ if (unit === 'hour')
181
+ return this;
182
+ d.setHours(0);
183
+ if (unit === 'day')
184
+ return this;
185
+ d.setDate(0);
186
+ if (unit === 'month')
187
+ return this;
188
+ d.setMonth(0);
189
+ return this;
190
+ }
191
+ const c = this.components();
192
+ c.second = 0;
193
+ if (unit === 'year') {
194
+ c.month = c.day = 1;
195
+ c.hour = c.minute = 0;
196
+ }
197
+ else if (unit === 'month') {
198
+ c.day = 1;
199
+ c.hour = c.minute = 0;
200
+ }
201
+ else if (unit === 'day') {
202
+ c.hour = c.minute = 0;
203
+ }
204
+ else if (unit === 'hour') {
205
+ c.minute = 0;
206
+ }
207
+ return LocalTime.fromComponents(c);
208
+ }
209
+ static sort(items, mutate = false, descending = false) {
210
+ const mod = descending ? -1 : 1;
211
+ return (mutate ? items : [...items]).sort((a, b) => {
212
+ const v1 = a.$date.valueOf();
213
+ const v2 = b.$date.valueOf();
214
+ if (v1 === v2)
215
+ return 0;
216
+ return (v1 < v2 ? -1 : 1) * mod;
217
+ });
218
+ }
219
+ static earliestOrUndefined(items) {
220
+ return items.length ? LocalTime.earliest(items) : undefined;
221
+ }
222
+ static earliest(items) {
223
+ (0, assert_1._assert)(items.length, 'LocalTime.earliest called on empty array');
224
+ return items.reduce((min, item) => (min.isSameOrBefore(item) ? min : item));
225
+ }
226
+ static latestOrUndefined(items) {
227
+ return items.length ? LocalTime.latest(items) : undefined;
228
+ }
229
+ static latest(items) {
230
+ (0, assert_1._assert)(items.length, 'LocalTime.latest called on empty array');
231
+ return items.reduce((max, item) => (max.isSameOrAfter(item) ? max : item));
232
+ }
233
+ isSame(d) {
234
+ return this.cmp(d) === 0;
235
+ }
236
+ isBefore(d) {
237
+ return this.cmp(d) === -1;
238
+ }
239
+ isSameOrBefore(d) {
240
+ return this.cmp(d) <= 0;
241
+ }
242
+ isAfter(d) {
243
+ return this.cmp(d) === 1;
244
+ }
245
+ isSameOrAfter(d) {
246
+ return this.cmp(d) >= 0;
247
+ }
248
+ /**
249
+ * Returns 1 if this > d
250
+ * returns 0 if they are equal
251
+ * returns -1 if this < d
252
+ */
253
+ cmp(d) {
254
+ const t1 = this.$date.valueOf();
255
+ const t2 = LocalTime.of(d).$date.valueOf();
256
+ if (t1 === t2)
257
+ return 0;
258
+ return t1 < t2 ? -1 : 1;
259
+ }
260
+ // todo: endOf
261
+ components() {
262
+ return {
263
+ year: this.$date.getFullYear(),
264
+ month: this.$date.getMonth() + 1,
265
+ day: this.$date.getDate(),
266
+ hour: this.$date.getHours(),
267
+ minute: this.$date.getMinutes(),
268
+ second: this.$date.getSeconds(),
269
+ };
270
+ }
271
+ getDate() {
272
+ return this.$date;
273
+ }
274
+ clone() {
275
+ return new LocalTime(new Date(this.$date));
276
+ }
277
+ unix() {
278
+ return Math.floor(this.$date.valueOf() / 1000);
279
+ }
280
+ valueOf() {
281
+ return Math.floor(this.$date.valueOf() / 1000);
282
+ }
283
+ toISO8601() {
284
+ return this.$date.toISOString().slice(0, 19);
285
+ }
286
+ toPretty() {
287
+ return this.$date.toISOString().slice(0, 19).split('T').join(' ');
288
+ }
289
+ toString() {
290
+ return String(this.unix());
291
+ }
292
+ toJSON() {
293
+ return this.unix();
294
+ }
295
+ }
296
+ exports.LocalTime = LocalTime;
297
+ /**
298
+ * Shortcut wrapper around `LocalDate.parse` / `LocalDate.today`
299
+ */
300
+ function localTime(d) {
301
+ return d ? LocalTime.of(d) : LocalTime.now();
302
+ }
303
+ exports.localTime = localTime;
304
+ // todo: range
@@ -2,9 +2,9 @@ export interface PromiseDecoratorCfg<RES = any, PARAMS = any> {
2
2
  decoratorName: string;
3
3
  /**
4
4
  * Called BEFORE the original function.
5
- * Returns void.
5
+ * If Promise is returned - it will be awaited.
6
6
  */
7
- beforeFn?: (r: PromiseDecoratorResp<PARAMS>) => void;
7
+ beforeFn?: (r: PromiseDecoratorResp<PARAMS>) => void | Promise<void>;
8
8
  /**
9
9
  * Called just AFTER the original function.
10
10
  * The output of this hook will be passed further,
@@ -24,12 +24,11 @@ function _createPromiseDecorator(cfg, decoratorParams = {}) {
24
24
  pd.value = async function (...args) {
25
25
  // console.log(`@${cfg.decoratorName} called inside function`)
26
26
  const started = Date.now();
27
- return (Promise.resolve()
27
+ try {
28
28
  // Before function
29
- .then(() => {
30
29
  // console.log(`@${cfg.decoratorName} Before`)
31
30
  if (cfg.beforeFn) {
32
- return cfg.beforeFn({
31
+ await cfg.beforeFn({
33
32
  decoratorParams,
34
33
  args,
35
34
  key,
@@ -38,10 +37,8 @@ function _createPromiseDecorator(cfg, decoratorParams = {}) {
38
37
  started,
39
38
  });
40
39
  }
41
- })
42
40
  // Original function
43
- .then(() => originalMethod.apply(this, args))
44
- .then(res => {
41
+ let res = await originalMethod.apply(this, args);
45
42
  // console.log(`${cfg.decoratorName} After`)
46
43
  const resp = {
47
44
  decoratorParams,
@@ -59,8 +56,8 @@ function _createPromiseDecorator(cfg, decoratorParams = {}) {
59
56
  }
60
57
  cfg.finallyFn?.(resp);
61
58
  return res;
62
- })
63
- .catch(err => {
59
+ }
60
+ catch (err) {
64
61
  console.error(`@${decoratorName} ${methodSignature} catch:`, err);
65
62
  const resp = {
66
63
  decoratorParams,
@@ -82,10 +79,7 @@ function _createPromiseDecorator(cfg, decoratorParams = {}) {
82
79
  if (!handled) {
83
80
  throw err; // rethrow
84
81
  }
85
- })
86
- // es2018 only
87
- // .finally(() => {})
88
- );
82
+ }
89
83
  };
90
84
  return pd;
91
85
  };
package/dist/index.d.ts CHANGED
@@ -60,5 +60,10 @@ export * from './string/safeJsonStringify';
60
60
  import { PQueue, PQueueCfg } from './promise/pQueue';
61
61
  export * from './seq/seq';
62
62
  export * from './math/stack.util';
63
- export type { AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, AsyncMemoCache, 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, Integer, BaseDBEntity, SavedDBEntity, Saved, Unsaved, CreatedUpdated, CreatedUpdatedId, ObjectWithId, AnyObjectWithId, JsonSchema, JsonSchemaAny, JsonSchemaOneOf, JsonSchemaAllOf, JsonSchemaAnyOf, JsonSchemaNot, JsonSchemaRef, JsonSchemaConst, JsonSchemaEnum, JsonSchemaString, JsonSchemaNumber, JsonSchemaBoolean, JsonSchemaNull, JsonSchemaRootObject, JsonSchemaObject, JsonSchemaArray, JsonSchemaTuple, JsonSchemaBuilder, CommonLogLevel, CommonLogWithLevelFunction, CommonLogFunction, CommonLogger, };
63
+ export * from './string/leven';
64
+ export * from './datetime/localDate';
65
+ export * from './datetime/localTime';
66
+ import { LocalDateConfig, LocalDateUnit } from './datetime/localDate';
67
+ import { LocalTimeConfig, LocalTimeUnit, LocalTimeComponents } from './datetime/localTime';
68
+ export type { LocalDateConfig, LocalDateUnit, LocalTimeConfig, LocalTimeUnit, LocalTimeComponents, AbortableMapper, AbortablePredicate, AbortableAsyncPredicate, AbortableAsyncMapper, PQueueCfg, MemoCache, AsyncMemoCache, 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, Integer, 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, };
64
69
  export { is, _createPromiseDecorator, _stringMapValues, _stringMapEntries, _objectKeys, pMap, _passthroughMapper, _passUndefinedMapper, _passthroughPredicate, _passNothingPredicate, _noop, ErrorMode, pDefer, AggregatedError, pRetry, pRetryFn, pTimeout, pTimeoutFn, _tryCatch, _TryCatch, _stringifyAny, jsonSchema, JsonSchemaAnyBuilder, commonLoggerMinLevel, commonLoggerNoop, commonLogLevelNumber, commonLoggerPipe, commonLoggerPrefix, commonLoggerCreate, PQueue, END, SKIP, };
package/dist/index.js CHANGED
@@ -2,70 +2,70 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SKIP = exports.END = exports.PQueue = exports.commonLoggerCreate = exports.commonLoggerPrefix = exports.commonLoggerPipe = exports.commonLogLevelNumber = exports.commonLoggerNoop = exports.commonLoggerMinLevel = exports.JsonSchemaAnyBuilder = exports.jsonSchema = exports._stringifyAny = exports._TryCatch = exports._tryCatch = exports.pTimeoutFn = exports.pTimeout = exports.pRetryFn = exports.pRetry = exports.AggregatedError = exports.pDefer = exports.ErrorMode = exports._noop = exports._passNothingPredicate = exports._passthroughPredicate = exports._passUndefinedMapper = exports._passthroughMapper = exports.pMap = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._createPromiseDecorator = exports.is = void 0;
4
4
  const tslib_1 = require("tslib");
5
- (0, tslib_1.__exportStar)(require("./array/array.util"), exports);
6
- (0, tslib_1.__exportStar)(require("./lazy"), exports);
7
- (0, tslib_1.__exportStar)(require("./string/url.util"), exports);
8
- (0, tslib_1.__exportStar)(require("./array/range"), exports);
5
+ tslib_1.__exportStar(require("./array/array.util"), exports);
6
+ tslib_1.__exportStar(require("./lazy"), exports);
7
+ tslib_1.__exportStar(require("./string/url.util"), exports);
8
+ tslib_1.__exportStar(require("./array/range"), exports);
9
9
  const createPromiseDecorator_1 = require("./decorators/createPromiseDecorator");
10
10
  Object.defineProperty(exports, "_createPromiseDecorator", { enumerable: true, get: function () { return createPromiseDecorator_1._createPromiseDecorator; } });
11
- (0, tslib_1.__exportStar)(require("./decorators/debounce"), exports);
12
- (0, tslib_1.__exportStar)(require("./decorators/debounce.decorator"), exports);
13
- (0, tslib_1.__exportStar)(require("./decorators/decorator.util"), exports);
14
- (0, tslib_1.__exportStar)(require("./decorators/logMethod.decorator"), exports);
15
- (0, tslib_1.__exportStar)(require("./decorators/memo.decorator"), exports);
16
- (0, tslib_1.__exportStar)(require("./decorators/asyncMemo.decorator"), exports);
17
- (0, tslib_1.__exportStar)(require("./decorators/memoFn"), exports);
18
- (0, tslib_1.__exportStar)(require("./decorators/memoFnAsync"), exports);
19
- (0, tslib_1.__exportStar)(require("./decorators/retry.decorator"), exports);
20
- (0, tslib_1.__exportStar)(require("./decorators/timeout.decorator"), exports);
21
- (0, tslib_1.__exportStar)(require("./error/app.error"), exports);
22
- (0, tslib_1.__exportStar)(require("./error/assert"), exports);
23
- (0, tslib_1.__exportStar)(require("./error/error.util"), exports);
11
+ tslib_1.__exportStar(require("./decorators/debounce"), exports);
12
+ tslib_1.__exportStar(require("./decorators/debounce.decorator"), exports);
13
+ tslib_1.__exportStar(require("./decorators/decorator.util"), exports);
14
+ tslib_1.__exportStar(require("./decorators/logMethod.decorator"), exports);
15
+ tslib_1.__exportStar(require("./decorators/memo.decorator"), exports);
16
+ tslib_1.__exportStar(require("./decorators/asyncMemo.decorator"), exports);
17
+ tslib_1.__exportStar(require("./decorators/memoFn"), exports);
18
+ tslib_1.__exportStar(require("./decorators/memoFnAsync"), exports);
19
+ tslib_1.__exportStar(require("./decorators/retry.decorator"), exports);
20
+ tslib_1.__exportStar(require("./decorators/timeout.decorator"), exports);
21
+ tslib_1.__exportStar(require("./error/app.error"), exports);
22
+ tslib_1.__exportStar(require("./error/assert"), exports);
23
+ tslib_1.__exportStar(require("./error/error.util"), exports);
24
24
  const errorMode_1 = require("./error/errorMode");
25
25
  Object.defineProperty(exports, "ErrorMode", { enumerable: true, get: function () { return errorMode_1.ErrorMode; } });
26
- (0, tslib_1.__exportStar)(require("./error/http.error"), exports);
27
- (0, tslib_1.__exportStar)(require("./error/try"), exports);
26
+ tslib_1.__exportStar(require("./error/http.error"), exports);
27
+ tslib_1.__exportStar(require("./error/try"), exports);
28
28
  const tryCatch_1 = require("./error/tryCatch");
29
29
  Object.defineProperty(exports, "_TryCatch", { enumerable: true, get: function () { return tryCatch_1._TryCatch; } });
30
30
  Object.defineProperty(exports, "_tryCatch", { enumerable: true, get: function () { return tryCatch_1._tryCatch; } });
31
- (0, tslib_1.__exportStar)(require("./json-schema/from-data/generateJsonSchemaFromData"), exports);
32
- (0, tslib_1.__exportStar)(require("./json-schema/jsonSchema.cnst"), exports);
33
- (0, tslib_1.__exportStar)(require("./json-schema/jsonSchema.util"), exports);
31
+ tslib_1.__exportStar(require("./json-schema/from-data/generateJsonSchemaFromData"), exports);
32
+ tslib_1.__exportStar(require("./json-schema/jsonSchema.cnst"), exports);
33
+ tslib_1.__exportStar(require("./json-schema/jsonSchema.util"), exports);
34
34
  const jsonSchemaBuilder_1 = require("./json-schema/jsonSchemaBuilder");
35
35
  Object.defineProperty(exports, "jsonSchema", { enumerable: true, get: function () { return jsonSchemaBuilder_1.jsonSchema; } });
36
36
  Object.defineProperty(exports, "JsonSchemaAnyBuilder", { enumerable: true, get: function () { return jsonSchemaBuilder_1.JsonSchemaAnyBuilder; } });
37
- (0, tslib_1.__exportStar)(require("./math/math.util"), exports);
38
- (0, tslib_1.__exportStar)(require("./math/sma"), exports);
39
- (0, tslib_1.__exportStar)(require("./number/createDeterministicRandom"), exports);
40
- (0, tslib_1.__exportStar)(require("./number/number.util"), exports);
41
- (0, tslib_1.__exportStar)(require("./object/deepEquals"), exports);
42
- (0, tslib_1.__exportStar)(require("./object/object.util"), exports);
43
- (0, tslib_1.__exportStar)(require("./object/sortObject"), exports);
44
- (0, tslib_1.__exportStar)(require("./object/sortObjectDeep"), exports);
37
+ tslib_1.__exportStar(require("./math/math.util"), exports);
38
+ tslib_1.__exportStar(require("./math/sma"), exports);
39
+ tslib_1.__exportStar(require("./number/createDeterministicRandom"), exports);
40
+ tslib_1.__exportStar(require("./number/number.util"), exports);
41
+ tslib_1.__exportStar(require("./object/deepEquals"), exports);
42
+ tslib_1.__exportStar(require("./object/object.util"), exports);
43
+ tslib_1.__exportStar(require("./object/sortObject"), exports);
44
+ tslib_1.__exportStar(require("./object/sortObjectDeep"), exports);
45
45
  const AggregatedError_1 = require("./promise/AggregatedError");
46
46
  Object.defineProperty(exports, "AggregatedError", { enumerable: true, get: function () { return AggregatedError_1.AggregatedError; } });
47
47
  const pDefer_1 = require("./promise/pDefer");
48
48
  Object.defineProperty(exports, "pDefer", { enumerable: true, get: function () { return pDefer_1.pDefer; } });
49
- (0, tslib_1.__exportStar)(require("./promise/pDelay"), exports);
50
- (0, tslib_1.__exportStar)(require("./promise/pFilter"), exports);
51
- (0, tslib_1.__exportStar)(require("./promise/pHang"), exports);
49
+ tslib_1.__exportStar(require("./promise/pDelay"), exports);
50
+ tslib_1.__exportStar(require("./promise/pFilter"), exports);
51
+ tslib_1.__exportStar(require("./promise/pHang"), exports);
52
52
  const pMap_1 = require("./promise/pMap");
53
53
  Object.defineProperty(exports, "pMap", { enumerable: true, get: function () { return pMap_1.pMap; } });
54
- (0, tslib_1.__exportStar)(require("./promise/pProps"), exports);
54
+ tslib_1.__exportStar(require("./promise/pProps"), exports);
55
55
  const pRetry_1 = require("./promise/pRetry");
56
56
  Object.defineProperty(exports, "pRetry", { enumerable: true, get: function () { return pRetry_1.pRetry; } });
57
57
  Object.defineProperty(exports, "pRetryFn", { enumerable: true, get: function () { return pRetry_1.pRetryFn; } });
58
- (0, tslib_1.__exportStar)(require("./promise/pState"), exports);
58
+ tslib_1.__exportStar(require("./promise/pState"), exports);
59
59
  const pTimeout_1 = require("./promise/pTimeout");
60
60
  Object.defineProperty(exports, "pTimeout", { enumerable: true, get: function () { return pTimeout_1.pTimeout; } });
61
61
  Object.defineProperty(exports, "pTimeoutFn", { enumerable: true, get: function () { return pTimeout_1.pTimeoutFn; } });
62
- (0, tslib_1.__exportStar)(require("./promise/pTuple"), exports);
63
- (0, tslib_1.__exportStar)(require("./string/case"), exports);
64
- (0, tslib_1.__exportStar)(require("./string/json.util"), exports);
65
- (0, tslib_1.__exportStar)(require("./string/string.util"), exports);
62
+ tslib_1.__exportStar(require("./promise/pTuple"), exports);
63
+ tslib_1.__exportStar(require("./string/case"), exports);
64
+ tslib_1.__exportStar(require("./string/json.util"), exports);
65
+ tslib_1.__exportStar(require("./string/string.util"), exports);
66
66
  const stringifyAny_1 = require("./string/stringifyAny");
67
67
  Object.defineProperty(exports, "_stringifyAny", { enumerable: true, get: function () { return stringifyAny_1._stringifyAny; } });
68
- (0, tslib_1.__exportStar)(require("./time/time.util"), exports);
68
+ tslib_1.__exportStar(require("./time/time.util"), exports);
69
69
  const types_1 = require("./types");
70
70
  Object.defineProperty(exports, "END", { enumerable: true, get: function () { return types_1.END; } });
71
71
  Object.defineProperty(exports, "SKIP", { enumerable: true, get: function () { return types_1.SKIP; } });
@@ -77,7 +77,7 @@ Object.defineProperty(exports, "_passthroughPredicate", { enumerable: true, get:
77
77
  Object.defineProperty(exports, "_passUndefinedMapper", { enumerable: true, get: function () { return types_1._passUndefinedMapper; } });
78
78
  Object.defineProperty(exports, "_stringMapEntries", { enumerable: true, get: function () { return types_1._stringMapEntries; } });
79
79
  Object.defineProperty(exports, "_stringMapValues", { enumerable: true, get: function () { return types_1._stringMapValues; } });
80
- (0, tslib_1.__exportStar)(require("./unit/size.util"), exports);
80
+ tslib_1.__exportStar(require("./unit/size.util"), exports);
81
81
  const is_1 = require("./vendor/is");
82
82
  Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.is; } });
83
83
  const commonLogger_1 = require("./log/commonLogger");
@@ -87,8 +87,11 @@ Object.defineProperty(exports, "commonLogLevelNumber", { enumerable: true, get:
87
87
  Object.defineProperty(exports, "commonLoggerPipe", { enumerable: true, get: function () { return commonLogger_1.commonLoggerPipe; } });
88
88
  Object.defineProperty(exports, "commonLoggerPrefix", { enumerable: true, get: function () { return commonLogger_1.commonLoggerPrefix; } });
89
89
  Object.defineProperty(exports, "commonLoggerCreate", { enumerable: true, get: function () { return commonLogger_1.commonLoggerCreate; } });
90
- (0, tslib_1.__exportStar)(require("./string/safeJsonStringify"), exports);
90
+ tslib_1.__exportStar(require("./string/safeJsonStringify"), exports);
91
91
  const pQueue_1 = require("./promise/pQueue");
92
92
  Object.defineProperty(exports, "PQueue", { enumerable: true, get: function () { return pQueue_1.PQueue; } });
93
- (0, tslib_1.__exportStar)(require("./seq/seq"), exports);
94
- (0, tslib_1.__exportStar)(require("./math/stack.util"), exports);
93
+ tslib_1.__exportStar(require("./seq/seq"), exports);
94
+ tslib_1.__exportStar(require("./math/stack.util"), exports);
95
+ tslib_1.__exportStar(require("./string/leven"), exports);
96
+ tslib_1.__exportStar(require("./datetime/localDate"), exports);
97
+ tslib_1.__exportStar(require("./datetime/localTime"), exports);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Modified version of: https://github.com/sindresorhus/leven/
3
+ *
4
+ * Returns a Levenshtein distance between first and second word.
5
+ */
6
+ export declare function _leven(first: string, second: string): number;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._leven = void 0;
4
+ const array = [];
5
+ const characterCodeCache = [];
6
+ /* eslint-disable unicorn/prefer-code-point, no-bitwise */
7
+ /**
8
+ * Modified version of: https://github.com/sindresorhus/leven/
9
+ *
10
+ * Returns a Levenshtein distance between first and second word.
11
+ */
12
+ function _leven(first, second) {
13
+ if (first === second) {
14
+ return 0;
15
+ }
16
+ const swap = first;
17
+ // Swapping the strings if `a` is longer than `b` so we know which one is the
18
+ // shortest & which one is the longest
19
+ if (first.length > second.length) {
20
+ first = second;
21
+ second = swap;
22
+ }
23
+ let firstLength = first.length;
24
+ let secondLength = second.length;
25
+ // Performing suffix trimming:
26
+ // We can linearly drop suffix common to both strings since they
27
+ // don't increase distance at all
28
+ // Note: `~-` is the bitwise way to perform a `- 1` operation
29
+ while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) {
30
+ firstLength--;
31
+ secondLength--;
32
+ }
33
+ // Performing prefix trimming
34
+ // We can linearly drop prefix common to both strings since they
35
+ // don't increase distance at all
36
+ let start = 0;
37
+ while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) {
38
+ start++;
39
+ }
40
+ firstLength -= start;
41
+ secondLength -= start;
42
+ if (firstLength === 0) {
43
+ return secondLength;
44
+ }
45
+ let bCharacterCode;
46
+ let result;
47
+ let temporary;
48
+ let temporary2;
49
+ let index = 0;
50
+ let index2 = 0;
51
+ while (index < firstLength) {
52
+ characterCodeCache[index] = first.charCodeAt(start + index);
53
+ array[index] = ++index;
54
+ }
55
+ while (index2 < secondLength) {
56
+ bCharacterCode = second.charCodeAt(start + index2);
57
+ temporary = index2++;
58
+ result = index2;
59
+ for (index = 0; index < firstLength; index++) {
60
+ temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1;
61
+ temporary = array[index];
62
+ // eslint-disable-next-line no-multi-assign
63
+ result = array[index] =
64
+ temporary > result
65
+ ? temporary2 > result
66
+ ? result + 1
67
+ : temporary2
68
+ : temporary2 > temporary
69
+ ? temporary + 1
70
+ : temporary2;
71
+ }
72
+ }
73
+ return result;
74
+ }
75
+ exports._leven = _leven;