@naturalcycles/js-lib 14.274.0 → 14.275.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.
Files changed (96) hide show
  1. package/cfg/frontend/tsconfig.json +1 -0
  2. package/dist/array/array.util.d.ts +1 -1
  3. package/dist/bot.js +4 -0
  4. package/dist/browser/adminService.d.ts +1 -1
  5. package/dist/browser/adminService.js +3 -2
  6. package/dist/browser/i18n/fetchTranslationLoader.d.ts +3 -3
  7. package/dist/browser/i18n/fetchTranslationLoader.js +1 -0
  8. package/dist/browser/i18n/translation.service.d.ts +1 -1
  9. package/dist/browser/i18n/translation.service.js +6 -0
  10. package/dist/browser/imageFitter.js +3 -1
  11. package/dist/datetime/dateInterval.d.ts +2 -2
  12. package/dist/datetime/dateInterval.js +2 -0
  13. package/dist/datetime/localDate.d.ts +1 -1
  14. package/dist/datetime/localDate.js +3 -0
  15. package/dist/datetime/localTime.d.ts +1 -1
  16. package/dist/datetime/localTime.js +1 -0
  17. package/dist/datetime/timeInterval.d.ts +1 -1
  18. package/dist/datetime/timeInterval.js +2 -0
  19. package/dist/datetime/wallTime.d.ts +2 -2
  20. package/dist/datetime/wallTime.js +6 -0
  21. package/dist/decorators/asyncMemo.decorator.d.ts +2 -2
  22. package/dist/decorators/memo.decorator.d.ts +2 -3
  23. package/dist/decorators/memo.util.js +3 -4
  24. package/dist/decorators/memoFn.d.ts +1 -1
  25. package/dist/decorators/memoFnAsync.d.ts +1 -1
  26. package/dist/deviceIdService.js +8 -0
  27. package/dist/env.js +2 -3
  28. package/dist/error/error.model.d.ts +2 -2
  29. package/dist/error/error.util.js +5 -0
  30. package/dist/http/fetcher.d.ts +2 -2
  31. package/dist/http/fetcher.js +23 -2
  32. package/dist/index.d.ts +0 -5
  33. package/dist/index.js +0 -7
  34. package/dist/iter/asyncIterable2.d.ts +3 -2
  35. package/dist/iter/asyncIterable2.js +1 -0
  36. package/dist/iter/iterable2.d.ts +2 -1
  37. package/dist/iter/iterable2.js +1 -0
  38. package/dist/json-schema/jsonSchema.util.d.ts +1 -1
  39. package/dist/json-schema/jsonSchemaBuilder.js +26 -25
  40. package/dist/math/accumulatingAverage.js +2 -4
  41. package/dist/math/sma.js +6 -4
  42. package/dist/math/stack.util.js +7 -6
  43. package/dist/object/object.util.d.ts +2 -1
  44. package/dist/promise/abortable.d.ts +1 -1
  45. package/dist/promise/abortable.js +2 -1
  46. package/dist/promise/pDelay.d.ts +1 -1
  47. package/dist/promise/pQueue.js +4 -3
  48. package/dist/promise/pTimeout.d.ts +1 -1
  49. package/dist/semver.d.ts +1 -1
  50. package/dist/semver.js +7 -6
  51. package/dist/string/hash.util.d.ts +1 -1
  52. package/dist/string/json.util.d.ts +1 -1
  53. package/dist/string/pupa.js +1 -0
  54. package/dist/web.d.ts +1 -1
  55. package/dist/web.js +1 -0
  56. package/dist/zod/index.d.ts +6 -0
  57. package/dist/zod/index.js +10 -0
  58. package/dist/zod/zod.util.js +2 -0
  59. package/dist-esm/array/array.util.js +1 -1
  60. package/dist-esm/decorators/asyncMemo.decorator.js +1 -1
  61. package/dist-esm/env.js +2 -3
  62. package/dist-esm/index.js +0 -4
  63. package/dist-esm/object/object.util.js +1 -1
  64. package/dist-esm/zod/index.js +4 -0
  65. package/package.json +1 -1
  66. package/src/array/array.util.ts +2 -2
  67. package/src/browser/adminService.ts +1 -1
  68. package/src/browser/i18n/fetchTranslationLoader.ts +3 -3
  69. package/src/browser/i18n/translation.service.ts +1 -1
  70. package/src/datetime/dateInterval.ts +3 -2
  71. package/src/datetime/localDate.ts +2 -1
  72. package/src/datetime/localTime.ts +2 -1
  73. package/src/datetime/timeInterval.ts +2 -1
  74. package/src/datetime/wallTime.ts +3 -2
  75. package/src/decorators/asyncMemo.decorator.ts +4 -9
  76. package/src/decorators/memo.decorator.ts +4 -3
  77. package/src/decorators/memoFn.ts +1 -1
  78. package/src/decorators/memoFnAsync.ts +2 -1
  79. package/src/decorators/swarmSafe.decorator.ts +1 -1
  80. package/src/env.ts +2 -3
  81. package/src/error/error.model.ts +2 -2
  82. package/src/error/error.util.ts +1 -1
  83. package/src/http/fetcher.ts +3 -3
  84. package/src/index.ts +0 -6
  85. package/src/iter/asyncIterable2.ts +3 -2
  86. package/src/iter/iterable2.ts +2 -1
  87. package/src/json-schema/jsonSchema.util.ts +2 -1
  88. package/src/object/object.util.ts +2 -3
  89. package/src/promise/abortable.ts +1 -1
  90. package/src/promise/pDelay.ts +2 -1
  91. package/src/promise/pTimeout.ts +2 -1
  92. package/src/semver.ts +1 -1
  93. package/src/string/hash.util.ts +1 -1
  94. package/src/string/json.util.ts +1 -1
  95. package/src/web.ts +1 -1
  96. package/src/zod/index.ts +7 -0
@@ -35,6 +35,7 @@
35
35
  "resolveJsonModule": true,
36
36
  "suppressImplicitAnyIndexErrors": false,
37
37
  "noUncheckedIndexedAccess": true,
38
+ "noUncheckedSideEffectImports": true,
38
39
  "noPropertyAccessFromIndexSignature": true,
39
40
  "noImplicitOverride": true,
40
41
 
@@ -1,4 +1,4 @@
1
- import { AbortablePredicate, FalsyValue, Mapper, Predicate, SortDirection, StringMap } from '../types';
1
+ import type { AbortablePredicate, FalsyValue, Mapper, Predicate, SortDirection, StringMap } from '../types';
2
2
  /**
3
3
  * Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
4
4
  * final chunk will be the remaining elements.
package/dist/bot.js CHANGED
@@ -11,9 +11,13 @@ const botRegex = /bot|spider|crawl|headless|electron|phantom|slimer|proximic|cin
11
11
  * @experimental
12
12
  */
13
13
  class BotDetectionService {
14
+ cfg;
14
15
  constructor(cfg = {}) {
15
16
  this.cfg = cfg;
16
17
  }
18
+ // memoized results
19
+ botReason;
20
+ cdp;
17
21
  isBotOrCDP() {
18
22
  return !!this.getBotReason() || this.isCDP();
19
23
  }
@@ -1,4 +1,4 @@
1
- import { Promisable } from '../typeFest';
1
+ import type { Promisable } from '../typeFest';
2
2
  export interface AdminModeCfg {
3
3
  /**
4
4
  * Function (predicate) to detect if needed keys are pressed.
@@ -17,8 +17,6 @@ const NOOP = () => { };
17
17
  */
18
18
  class AdminService {
19
19
  constructor(cfg) {
20
- this.adminMode = false;
21
- this.listening = false;
22
20
  this.cfg = {
23
21
  predicate: e => e.ctrlKey && e.key === 'L',
24
22
  persistToLocalStorage: true,
@@ -30,6 +28,9 @@ class AdminService {
30
28
  ...cfg,
31
29
  };
32
30
  }
31
+ cfg;
32
+ adminMode = false;
33
+ listening = false;
33
34
  /**
34
35
  * Start listening to keyboard events to toggle AdminMode when detected.
35
36
  */
@@ -1,6 +1,6 @@
1
- import { Fetcher } from '../../http/fetcher';
2
- import { StringMap } from '../../types';
3
- import { TranslationLoader } from './translation.service';
1
+ import type { Fetcher } from '../../http/fetcher';
2
+ import type { StringMap } from '../../types';
3
+ import type { TranslationLoader } from './translation.service';
4
4
  /**
5
5
  * Use `baseUrl` to prefix your language files.
6
6
  * Example URL structure:
@@ -7,6 +7,7 @@ exports.FetchTranslationLoader = void 0;
7
7
  * ${baseUrl}/${locale}.json
8
8
  */
9
9
  class FetchTranslationLoader {
10
+ fetcher;
10
11
  constructor(fetcher) {
11
12
  this.fetcher = fetcher;
12
13
  }
@@ -1,4 +1,4 @@
1
- import { StringMap } from '../../types';
1
+ import type { StringMap } from '../../types';
2
2
  export type MissingTranslationHandler = (key: string, params?: StringMap<any>) => string;
3
3
  export declare const defaultMissingTranslationHandler: MissingTranslationHandler;
4
4
  export interface TranslationServiceCfg {
@@ -18,6 +18,12 @@ class TranslationService {
18
18
  };
19
19
  this.currentLocale = cfg.currentLocale || cfg.defaultLocale;
20
20
  }
21
+ cfg;
22
+ /**
23
+ * Cache of loaded locales
24
+ */
25
+ locales;
26
+ currentLocale;
21
27
  /**
22
28
  * Manually set locale data, bypassing the TranslationLoader.
23
29
  */
@@ -10,7 +10,6 @@ exports.ImageFitter = void 0;
10
10
  */
11
11
  class ImageFitter {
12
12
  constructor(cfg) {
13
- this.containerWidth = -1;
14
13
  this.cfg = {
15
14
  maxHeight: 300,
16
15
  margin: 8,
@@ -19,6 +18,9 @@ class ImageFitter {
19
18
  this.resizeObserver = new ResizeObserver(entries => this.update(entries));
20
19
  this.resizeObserver.observe(cfg.containerElement);
21
20
  }
21
+ cfg;
22
+ resizeObserver;
23
+ containerWidth = -1;
22
24
  stop() {
23
25
  this.resizeObserver.disconnect();
24
26
  }
@@ -1,5 +1,5 @@
1
- import { Inclusiveness } from '../types';
2
- import { LocalDate, LocalDateInput, LocalDateUnit } from './localDate';
1
+ import type { Inclusiveness } from '../types';
2
+ import type { LocalDate, LocalDateInput, LocalDateUnit } from './localDate';
3
3
  export type DateIntervalConfig = DateInterval | DateIntervalString;
4
4
  export type DateIntervalString = string;
5
5
  /**
@@ -8,6 +8,8 @@ const localDate_1 = require("./localDate");
8
8
  * @experimental
9
9
  */
10
10
  class DateInterval {
11
+ start;
12
+ end;
11
13
  constructor(start, end) {
12
14
  this.start = start;
13
15
  this.end = end;
@@ -1,6 +1,6 @@
1
1
  import { Iterable2 } from '../iter/iterable2';
2
2
  import type { Inclusiveness, IsoDate, IsoDateTime, MonthId, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types';
3
- import { DateObject, ISODayOfWeek, LocalTime } from './localTime';
3
+ import type { DateObject, ISODayOfWeek, LocalTime } from './localTime';
4
4
  export type LocalDateUnit = LocalDateUnitStrict | 'week';
5
5
  export type LocalDateUnitStrict = 'year' | 'month' | 'day';
6
6
  export type LocalDateInput = LocalDate | Date | IsoDate;
@@ -15,6 +15,9 @@ const COMPACT_DATE_REGEX = /^(\d\d\d\d)(\d\d)(\d\d)$/;
15
15
  * It is timezone-independent.
16
16
  */
17
17
  class LocalDate {
18
+ year;
19
+ month;
20
+ day;
18
21
  constructor(year, month, day) {
19
22
  this.year = year;
20
23
  this.month = month;
@@ -1,5 +1,5 @@
1
1
  import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, MonthId, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types';
2
- import { LocalDate } from './localDate';
2
+ import type { LocalDate } from './localDate';
3
3
  import { WallTime } from './wallTime';
4
4
  export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
5
5
  export declare enum ISODayOfWeek {
@@ -37,6 +37,7 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
37
37
  const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/;
38
38
  const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
39
39
  class LocalTime {
40
+ $date;
40
41
  constructor($date) {
41
42
  this.$date = $date;
42
43
  }
@@ -1,5 +1,5 @@
1
1
  import type { Inclusiveness, UnixTimestamp } from '../types';
2
- import { LocalTime, LocalTimeInput } from './localTime';
2
+ import type { LocalTime, LocalTimeInput } from './localTime';
3
3
  export type TimeIntervalConfig = TimeInterval | TimeIntervalString;
4
4
  export type TimeIntervalString = string;
5
5
  /**
@@ -9,6 +9,8 @@ const localTime_1 = require("./localTime");
9
9
  * @experimental
10
10
  */
11
11
  class TimeInterval {
12
+ $start;
13
+ $end;
12
14
  constructor($start, $end) {
13
15
  this.$start = $start;
14
16
  this.$end = $end;
@@ -1,6 +1,6 @@
1
- import { IsoDate, IsoDateTime } from '../types';
1
+ import type { IsoDate, IsoDateTime } from '../types';
2
2
  import { LocalDate } from './localDate';
3
- import { DateTimeObject, LocalTime } from './localTime';
3
+ import type { DateTimeObject, LocalTime } from './localTime';
4
4
  /**
5
5
  * Representation of a "time on the wall clock",
6
6
  * which means "local time, regardless of timezone".
@@ -13,6 +13,12 @@ const localTime_1 = require("./localTime");
13
13
  * Can be pretty-printed as Date, Time or DateAndTime.
14
14
  */
15
15
  class WallTime {
16
+ year;
17
+ month;
18
+ day;
19
+ hour;
20
+ minute;
21
+ second;
16
22
  constructor(obj) {
17
23
  Object.assign(this, obj);
18
24
  }
@@ -1,6 +1,6 @@
1
1
  import type { CommonLogger } from '../log/commonLogger';
2
- import { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types';
3
- import { AsyncMemoCache, MethodDecorator } from './memo.util';
2
+ import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types';
3
+ import type { AsyncMemoCache, MethodDecorator } from './memo.util';
4
4
  export interface AsyncMemoOptions<FN> {
5
5
  /**
6
6
  * Provide a custom implementation of AsyncMemoCache.
@@ -1,7 +1,6 @@
1
1
  import type { CommonLogger } from '../log/commonLogger';
2
- import { AnyFunction, AnyObject, MaybeParameters } from '../types';
3
- import type { MemoCache } from './memo.util';
4
- import { MethodDecorator } from './memo.util';
2
+ import type { AnyFunction, AnyObject, MaybeParameters } from '../types';
3
+ import type { MemoCache, MethodDecorator } from './memo.util';
5
4
  export interface MemoOptions<FN> {
6
5
  /**
7
6
  * Provide a custom implementation of MemoCache.
@@ -58,9 +58,7 @@ export class ObjectMemoCache implements MemoCache {
58
58
  }
59
59
  */
60
60
  class MapMemoCache {
61
- constructor() {
62
- this.m = new Map();
63
- }
61
+ m = new Map();
64
62
  has(k) {
65
63
  return this.m.has(k);
66
64
  }
@@ -81,10 +79,11 @@ exports.MapMemoCache = MapMemoCache;
81
79
  * because the point of AsyncMemoCache is to have an **async** backed cache.
82
80
  */
83
81
  class MapAsyncMemoCache {
82
+ delay;
84
83
  constructor(delay = 0) {
85
84
  this.delay = delay;
86
- this.m = new Map();
87
85
  }
86
+ m = new Map();
88
87
  async get(k) {
89
88
  await (0, pDelay_1.pDelay)(this.delay);
90
89
  if (!this.m.has(k))
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '../types';
1
+ import type { AnyFunction } from '../types';
2
2
  import type { MemoOptions } from './memo.decorator';
3
3
  import type { MemoCache } from './memo.util';
4
4
  export interface MemoizedFunction {
@@ -1,4 +1,4 @@
1
- import { AnyAsyncFunction } from '../types';
1
+ import type { AnyAsyncFunction } from '../types';
2
2
  import type { AsyncMemoOptions } from './asyncMemo.decorator';
3
3
  import type { AsyncMemoCache } from './memo.util';
4
4
  export interface MemoizedAsyncFunction {
@@ -33,6 +33,14 @@ class DeviceIdService {
33
33
  };
34
34
  this.init();
35
35
  }
36
+ cfg;
37
+ /**
38
+ * `deviceId` is null only in anomalous cases, e.g when localStorage is not available (due to e.g "out of disk space" on device).
39
+ * In all other cases it should be defined and stable (persisted indefinitely between multiple visits).
40
+ *
41
+ * It is null if the service is run on the server side.
42
+ */
43
+ deviceId;
36
44
  /**
37
45
  * Selects this device based on "deterministic random selection", according to the defined `rate`.
38
46
  * Rate is a floating number between 0 and 1.
package/dist/env.js CHANGED
@@ -9,8 +9,7 @@ exports.isClientSide = isClientSide;
9
9
  * Will return `false` in the Browser.
10
10
  */
11
11
  function isServerSide() {
12
- // eslint-disable-next-line unicorn/prefer-global-this
13
- return typeof window === 'undefined';
12
+ return !isClientSide();
14
13
  }
15
14
  /**
16
15
  * Use it to detect Browser (not SSR/Node) environment.
@@ -20,5 +19,5 @@ function isServerSide() {
20
19
  */
21
20
  function isClientSide() {
22
21
  // eslint-disable-next-line unicorn/prefer-global-this
23
- return typeof window !== 'undefined';
22
+ return typeof window !== 'undefined' && !!window?.document;
24
23
  }
@@ -1,5 +1,5 @@
1
- import { HttpMethod, HttpStatusCode } from '../http/http.model';
2
- import { NumberOfMilliseconds } from '../types';
1
+ import type { HttpMethod, HttpStatusCode } from '../http/http.model';
2
+ import type { NumberOfMilliseconds } from '../types';
3
3
  /**
4
4
  * Extendable payload object to transfer custom additional data with AppError.
5
5
  */
@@ -237,6 +237,11 @@ function _errorDataAppend(err, data) {
237
237
  * Based on: https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801
238
238
  */
239
239
  class AppError extends Error {
240
+ data;
241
+ /**
242
+ * `cause` here is normalized to be an ErrorObject
243
+ */
244
+ cause;
240
245
  /**
241
246
  * Experimental alternative static constructor.
242
247
  */
@@ -2,8 +2,8 @@
2
2
  /// <reference lib="dom" preserve="true" />
3
3
  /// <reference lib="dom.iterable" preserve="true" />
4
4
  import { HttpRequestError } from '../error/error.util';
5
- import { ErrorDataTuple } from '../types';
6
- import { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherGraphQLOptions, FetcherNormalizedCfg, FetcherOnErrorHook, FetcherOptions, FetcherResponse, RequestInitNormalized } from './fetcher.model';
5
+ import type { ErrorDataTuple } from '../types';
6
+ import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherGraphQLOptions, FetcherNormalizedCfg, FetcherOnErrorHook, FetcherOptions, FetcherResponse, RequestInitNormalized } from './fetcher.model';
7
7
  /**
8
8
  * Experimental wrapper around Fetch.
9
9
  * Works in both Browser and Node, using `globalThis.fetch`.
@@ -41,8 +41,8 @@ class Fetcher {
41
41
  *
42
42
  * Version is to be incremented every time a difference in behaviour (or a bugfix) is done.
43
43
  */
44
- static { this.VERSION = 2; }
45
- static { this.userAgent = (0, env_1.isServerSide)() ? `fetcher${this.VERSION}` : undefined; }
44
+ static VERSION = 2;
45
+ static userAgent = (0, env_1.isServerSide)() ? `fetcher${this.VERSION}` : undefined;
46
46
  constructor(cfg = {}) {
47
47
  if (typeof globalThis.fetch !== 'function') {
48
48
  throw new TypeError('globalThis.fetch is not available');
@@ -103,9 +103,30 @@ class Fetcher {
103
103
  (this.cfg.hooks.onError ||= []).push(hook);
104
104
  return this;
105
105
  }
106
+ cfg;
106
107
  static create(cfg = {}) {
107
108
  return new Fetcher(cfg);
108
109
  }
110
+ // These methods are generated dynamically in the constructor
111
+ // These default methods use responseType=json
112
+ get;
113
+ post;
114
+ put;
115
+ patch;
116
+ delete;
117
+ // responseType=text
118
+ getText;
119
+ postText;
120
+ putText;
121
+ patchText;
122
+ deleteText;
123
+ // responseType=void (no body fetching/parsing)
124
+ getVoid;
125
+ postVoid;
126
+ putVoid;
127
+ patchVoid;
128
+ deleteVoid;
129
+ headVoid;
109
130
  /**
110
131
  * Small convenience wrapper that allows to issue GraphQL queries.
111
132
  * In practice, all it does is:
package/dist/index.d.ts CHANGED
@@ -94,8 +94,3 @@ export * from './typeFest';
94
94
  export * from './types';
95
95
  export * from './unit/size.util';
96
96
  export * from './web';
97
- export * from './zod/zod.shared.schemas';
98
- export * from './zod/zod.util';
99
- import { z, ZodError, ZodIssue, ZodSchema } from 'zod';
100
- export { z, ZodError, ZodSchema };
101
- export type { ZodIssue };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZodSchema = exports.ZodError = exports.z = void 0;
4
3
  const tslib_1 = require("tslib");
5
4
  tslib_1.__exportStar(require("./abort"), exports);
6
5
  tslib_1.__exportStar(require("./array/array.util"), exports);
@@ -98,9 +97,3 @@ tslib_1.__exportStar(require("./typeFest"), exports);
98
97
  tslib_1.__exportStar(require("./types"), exports);
99
98
  tslib_1.__exportStar(require("./unit/size.util"), exports);
100
99
  tslib_1.__exportStar(require("./web"), exports);
101
- tslib_1.__exportStar(require("./zod/zod.shared.schemas"), exports);
102
- tslib_1.__exportStar(require("./zod/zod.util"), exports);
103
- const zod_1 = require("zod");
104
- Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_1.z; } });
105
- Object.defineProperty(exports, "ZodError", { enumerable: true, get: function () { return zod_1.ZodError; } });
106
- Object.defineProperty(exports, "ZodSchema", { enumerable: true, get: function () { return zod_1.ZodSchema; } });
@@ -1,5 +1,6 @@
1
- import { Promisable } from '../typeFest';
2
- import { AbortableAsyncMapper, AbortableAsyncPredicate, END } from '../types';
1
+ import type { Promisable } from '../typeFest';
2
+ import type { AbortableAsyncMapper, AbortableAsyncPredicate } from '../types';
3
+ import { END } from '../types';
3
4
  /**
4
5
  * Similar to Iterable2, but for AsyncIterable.
5
6
  *
@@ -13,6 +13,7 @@ const types_1 = require("../types");
13
13
  * @experimental
14
14
  */
15
15
  class AsyncIterable2 {
16
+ it;
16
17
  constructor(it) {
17
18
  this.it = it;
18
19
  }
@@ -1,4 +1,5 @@
1
- import { AbortableMapper, AbortablePredicate, END } from '../types';
1
+ import type { AbortableMapper, AbortablePredicate } from '../types';
2
+ import { END } from '../types';
2
3
  /**
3
4
  * Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
4
5
  * https://github.com/tc39/proposal-iterator-helpers
@@ -11,6 +11,7 @@ const types_1 = require("../types");
11
11
  * @experimental
12
12
  */
13
13
  class Iterable2 {
14
+ it;
14
15
  constructor(it) {
15
16
  this.it = it;
16
17
  }
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../index';
1
+ import type { AnyObject } from '../index';
2
2
  import type { JsonSchemaObject } from './jsonSchema.model';
3
3
  /**
4
4
  * Merges s2 into s1 (mutates s1) and returns s1.
@@ -86,6 +86,7 @@ exports.jsonSchema = {
86
86
  },
87
87
  };
88
88
  class JsonSchemaAnyBuilder {
89
+ schema;
89
90
  constructor(schema) {
90
91
  this.schema = schema;
91
92
  }
@@ -165,16 +166,6 @@ class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder {
165
166
  super({
166
167
  type: 'number',
167
168
  });
168
- this.int32 = () => this.format('int32');
169
- this.int64 = () => this.format('int64');
170
- this.float = () => this.format('float');
171
- this.double = () => this.format('double');
172
- this.unixTimestamp = () => this.format('unixTimestamp');
173
- this.unixTimestamp2000 = () => this.format('unixTimestamp2000');
174
- this.unixTimestampMillis = () => this.format('unixTimestampMillis');
175
- this.unixTimestampMillis2000 = () => this.format('unixTimestampMillis2000');
176
- this.utcOffset = () => this.format('utcOffset');
177
- this.utcOffsetHours = () => this.format('utcOffsetHours');
178
169
  }
179
170
  integer() {
180
171
  Object.assign(this.schema, { type: 'integer' });
@@ -211,6 +202,16 @@ class JsonSchemaNumberBuilder extends JsonSchemaAnyBuilder {
211
202
  Object.assign(this.schema, { format });
212
203
  return this;
213
204
  }
205
+ int32 = () => this.format('int32');
206
+ int64 = () => this.format('int64');
207
+ float = () => this.format('float');
208
+ double = () => this.format('double');
209
+ unixTimestamp = () => this.format('unixTimestamp');
210
+ unixTimestamp2000 = () => this.format('unixTimestamp2000');
211
+ unixTimestampMillis = () => this.format('unixTimestampMillis');
212
+ unixTimestampMillis2000 = () => this.format('unixTimestampMillis2000');
213
+ utcOffset = () => this.format('utcOffset');
214
+ utcOffsetHours = () => this.format('utcOffsetHours');
214
215
  }
215
216
  exports.JsonSchemaNumberBuilder = JsonSchemaNumberBuilder;
216
217
  class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
@@ -218,21 +219,6 @@ class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
218
219
  super({
219
220
  type: 'string',
220
221
  });
221
- this.email = () => this.format('email');
222
- this.date = () => this.format('date');
223
- this.url = () => this.format('url');
224
- this.ipv4 = () => this.format('ipv4');
225
- this.ipv6 = () => this.format('ipv6');
226
- this.password = () => this.format('password');
227
- this.id = () => this.format('id');
228
- this.slug = () => this.format('slug');
229
- this.semVer = () => this.format('semVer');
230
- this.languageTag = () => this.format('languageTag');
231
- this.countryCode = () => this.format('countryCode');
232
- this.currency = () => this.format('currency');
233
- this.trim = (trim = true) => this.transformModify('trim', trim);
234
- this.toLowerCase = (toLowerCase = true) => this.transformModify('toLowerCase', toLowerCase);
235
- this.toUpperCase = (toUpperCase = true) => this.transformModify('toUpperCase', toUpperCase);
236
222
  }
237
223
  pattern(pattern) {
238
224
  Object.assign(this.schema, { pattern });
@@ -254,6 +240,21 @@ class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
254
240
  Object.assign(this.schema, { format });
255
241
  return this;
256
242
  }
243
+ email = () => this.format('email');
244
+ date = () => this.format('date');
245
+ url = () => this.format('url');
246
+ ipv4 = () => this.format('ipv4');
247
+ ipv6 = () => this.format('ipv6');
248
+ password = () => this.format('password');
249
+ id = () => this.format('id');
250
+ slug = () => this.format('slug');
251
+ semVer = () => this.format('semVer');
252
+ languageTag = () => this.format('languageTag');
253
+ countryCode = () => this.format('countryCode');
254
+ currency = () => this.format('currency');
255
+ trim = (trim = true) => this.transformModify('trim', trim);
256
+ toLowerCase = (toLowerCase = true) => this.transformModify('toLowerCase', toLowerCase);
257
+ toUpperCase = (toUpperCase = true) => this.transformModify('toUpperCase', toUpperCase);
257
258
  transformModify(t, add) {
258
259
  if (add) {
259
260
  this.schema.transform = (0, array_util_1._uniq)([...(this.schema.transform || []), t]);
@@ -8,10 +8,8 @@ exports.AccumulatingAverage = void 0;
8
8
  * @experimental
9
9
  */
10
10
  class AccumulatingAverage {
11
- constructor() {
12
- this.total = 0;
13
- this.count = 0;
14
- }
11
+ total = 0;
12
+ count = 0;
15
13
  /**
16
14
  * Returns the current average.
17
15
  * Returns 0 if no values have been added.
package/dist/math/sma.js CHANGED
@@ -5,14 +5,16 @@ exports.SimpleMovingAverage = void 0;
5
5
  * Implements a Simple Moving Average algorithm.
6
6
  */
7
7
  class SimpleMovingAverage {
8
+ size;
9
+ data;
8
10
  constructor(size, data = []) {
9
11
  this.size = size;
10
12
  this.data = data;
11
- /**
12
- * Next index of array to push to
13
- */
14
- this.nextIndex = 0;
15
13
  }
14
+ /**
15
+ * Next index of array to push to
16
+ */
17
+ nextIndex = 0;
16
18
  /**
17
19
  * Current average (calculated on the fly).
18
20
  * Returns 0 (not undefined) for empty data.
@@ -10,15 +10,16 @@ const index_1 = require("../index");
10
10
  *
11
11
  */
12
12
  class Stack {
13
+ size;
13
14
  constructor(size) {
14
15
  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
16
  }
17
+ /**
18
+ * Index of a slot to get written TO next.
19
+ * Currently this slot contains OLDEST item (if any).
20
+ */
21
+ nextIndex = 0;
22
+ items = [];
22
23
  push(item) {
23
24
  this.items[this.nextIndex] = item;
24
25
  this.nextIndex = this.nextIndex === this.size - 1 ? 0 : this.nextIndex + 1;
@@ -1,4 +1,5 @@
1
- import { AnyObject, KeyValueTuple, ObjectMapper, ObjectPredicate, Reviver, SKIP, ValueOf } from '../types';
1
+ import type { AnyObject, KeyValueTuple, ObjectMapper, ObjectPredicate, Reviver, ValueOf } from '../types';
2
+ import { SKIP } from '../types';
2
3
  /**
3
4
  * Returns clone of `obj` with only `props` preserved.
4
5
  * Opposite of Omit.
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '../types';
1
+ import type { AnyFunction } from '../types';
2
2
  /**
3
3
  * Similar to AbortController and AbortSignal.
4
4
  * Similar to pDefer and Promise.
@@ -14,10 +14,11 @@ exports.abortable = abortable;
14
14
  * @experimental
15
15
  */
16
16
  class Abortable {
17
+ onAbort;
17
18
  constructor(onAbort) {
18
19
  this.onAbort = onAbort;
19
- this.aborted = false;
20
20
  }
21
+ aborted = false;
21
22
  abort() {
22
23
  if (this.aborted)
23
24
  return;
@@ -1,5 +1,5 @@
1
1
  import type { NumberOfMilliseconds, PromisableFunction } from '../types';
2
- import { DeferredPromise } from './pDefer';
2
+ import type { DeferredPromise } from './pDefer';
3
3
  /**
4
4
  * Promisified version of setTimeout.
5
5
  *