@naturalcycles/js-lib 14.144.1 → 14.146.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 (40) hide show
  1. package/dist/array/array.util.js +2 -2
  2. package/dist/datetime/localDate.js +0 -1
  3. package/dist/datetime/localTime.js +0 -1
  4. package/dist/decorators/createPromiseDecorator.js +0 -1
  5. package/dist/http/fetcher.d.ts +27 -19
  6. package/dist/http/fetcher.js +60 -13
  7. package/dist/http/fetcher.model.d.ts +21 -8
  8. package/dist/object/object.util.js +0 -1
  9. package/dist/object/sortObjectDeep.js +0 -1
  10. package/dist/promise/abortable.d.ts +2 -2
  11. package/dist/promise/pMap.js +1 -1
  12. package/dist/string/leven.js +0 -1
  13. package/dist/string/string.util.js +0 -1
  14. package/dist/vendor/is.d.ts +1 -1
  15. package/dist/vendor/is.js +1 -7
  16. package/dist-esm/array/array.util.js +2 -2
  17. package/dist-esm/datetime/localDate.js +0 -1
  18. package/dist-esm/datetime/localTime.js +0 -1
  19. package/dist-esm/decorators/createPromiseDecorator.js +0 -1
  20. package/dist-esm/http/fetcher.js +61 -71
  21. package/dist-esm/object/object.util.js +0 -1
  22. package/dist-esm/object/sortObjectDeep.js +0 -1
  23. package/dist-esm/promise/pMap.js +15 -34
  24. package/dist-esm/string/leven.js +0 -1
  25. package/dist-esm/string/string.util.js +0 -1
  26. package/dist-esm/vendor/is.js +1 -7
  27. package/package.json +1 -1
  28. package/src/array/array.util.ts +2 -2
  29. package/src/datetime/localDate.ts +0 -2
  30. package/src/datetime/localTime.ts +0 -2
  31. package/src/decorators/createPromiseDecorator.ts +1 -1
  32. package/src/http/fetcher.model.ts +31 -8
  33. package/src/http/fetcher.ts +98 -46
  34. package/src/json-schema/jsonSchema.model.ts +0 -1
  35. package/src/object/object.util.ts +0 -1
  36. package/src/object/sortObjectDeep.ts +0 -1
  37. package/src/promise/pMap.ts +1 -1
  38. package/src/string/leven.ts +1 -1
  39. package/src/string/string.util.ts +0 -2
  40. package/src/vendor/is.ts +7 -10
@@ -144,7 +144,7 @@ exports._groupBy = _groupBy;
144
144
  function _sortBy(items, mapper, mutate = false, descending = false) {
145
145
  const mod = descending ? -1 : 1;
146
146
  return (mutate ? items : [...items]).sort((_a, _b) => {
147
- const [a, b] = [_a, _b].map(mapper); // eslint-disable-line unicorn/no-array-callback-reference
147
+ const [a, b] = [_a, _b].map(mapper);
148
148
  if (typeof a === 'number' && typeof b === 'number')
149
149
  return (a - b) * mod;
150
150
  return String(a).localeCompare(String(b)) * mod;
@@ -155,7 +155,7 @@ exports._sortBy = _sortBy;
155
155
  * Like items.find(), but it tries to find from the END of the array.
156
156
  */
157
157
  function _findLast(items, predicate) {
158
- return [...items].reverse().find(predicate); // eslint-disable-line unicorn/no-array-callback-reference
158
+ return [...items].reverse().find(predicate);
159
159
  }
160
160
  exports._findLast = _findLast;
161
161
  function _takeWhile(items, predicate) {
@@ -5,7 +5,6 @@ const assert_1 = require("../error/assert");
5
5
  const localTime_1 = require("./localTime");
6
6
  const MDAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7
7
  const DATE_REGEX = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
8
- /* eslint-disable no-dupe-class-members */
9
8
  /**
10
9
  * @experimental
11
10
  */
@@ -20,7 +20,6 @@ const SECONDS_IN_DAY = 86400;
20
20
  // const MILLISECONDS_IN_DAY = 86400000
21
21
  // const MILLISECONDS_IN_MINUTE = 60000
22
22
  const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
23
- /* eslint-disable no-dupe-class-members */
24
23
  /**
25
24
  * @experimental
26
25
  */
@@ -13,7 +13,6 @@ const decorator_util_1 = require("./decorator.util");
13
13
  *
14
14
  * @experimental
15
15
  */
16
- // eslint-disable-next-line @typescript-eslint/naming-convention
17
16
  function _createPromiseDecorator(cfg, decoratorParams = {}) {
18
17
  const { decoratorName } = cfg;
19
18
  return function decoratorFunction(target, propertyKey, pd) {
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="dom" />
2
- import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherNormalizedCfg, FetcherOptions, FetcherResponse } from './fetcher.model';
2
+ import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherNormalizedCfg, FetcherOptions, FetcherRequest, FetcherResponse } from './fetcher.model';
3
3
  /**
4
4
  * Experimental wrapper around Fetch.
5
5
  * Works in both Browser and Node, using `globalThis.fetch`.
@@ -14,29 +14,37 @@ export declare class Fetcher {
14
14
  onBeforeRetry(hook: FetcherBeforeRetryHook): this;
15
15
  cfg: FetcherNormalizedCfg;
16
16
  static create(cfg?: FetcherCfg & FetcherOptions): Fetcher;
17
- get: <T = unknown>(url: string, opt?: FetcherOptions) => Promise<T>;
18
- post: <T = unknown>(url: string, opt?: FetcherOptions) => Promise<T>;
19
- put: <T = unknown>(url: string, opt?: FetcherOptions) => Promise<T>;
20
- patch: <T = unknown>(url: string, opt?: FetcherOptions) => Promise<T>;
21
- delete: <T = unknown>(url: string, opt?: FetcherOptions) => Promise<T>;
22
- getText: (url: string, opt?: FetcherOptions) => Promise<string>;
23
- postText: (url: string, opt?: FetcherOptions) => Promise<string>;
24
- putText: (url: string, opt?: FetcherOptions) => Promise<string>;
25
- patchText: (url: string, opt?: FetcherOptions) => Promise<string>;
26
- deleteText: (url: string, opt?: FetcherOptions) => Promise<string>;
27
- getVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
28
- postVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
29
- putVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
30
- patchVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
31
- deleteVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
32
- headVoid: (url: string, opt?: FetcherOptions) => Promise<void>;
33
- fetch<T = unknown>(url: string, opt?: FetcherOptions): Promise<T>;
17
+ get: <T = unknown>(url: string, opt?: FetcherOptions<T>) => Promise<T>;
18
+ post: <T = unknown>(url: string, opt?: FetcherOptions<T>) => Promise<T>;
19
+ put: <T = unknown>(url: string, opt?: FetcherOptions<T>) => Promise<T>;
20
+ patch: <T = unknown>(url: string, opt?: FetcherOptions<T>) => Promise<T>;
21
+ delete: <T = unknown>(url: string, opt?: FetcherOptions<T>) => Promise<T>;
22
+ getText: (url: string, opt?: FetcherOptions<string>) => Promise<string>;
23
+ postText: (url: string, opt?: FetcherOptions<string>) => Promise<string>;
24
+ putText: (url: string, opt?: FetcherOptions<string>) => Promise<string>;
25
+ patchText: (url: string, opt?: FetcherOptions<string>) => Promise<string>;
26
+ deleteText: (url: string, opt?: FetcherOptions<string>) => Promise<string>;
27
+ getVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
28
+ postVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
29
+ putVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
30
+ patchVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
31
+ deleteVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
32
+ headVoid: (url: string, opt?: FetcherOptions<void>) => Promise<void>;
33
+ /**
34
+ * Returns raw fetchResponse.body, which is a ReadableStream<Uint8Array>
35
+ *
36
+ * More on streams and Node interop:
37
+ * https://css-tricks.com/web-streams-everywhere-and-fetch-for-node-js/
38
+ */
39
+ getReadableStream(url: string, opt?: FetcherOptions<ReadableStream<Uint8Array>>): Promise<ReadableStream<Uint8Array>>;
40
+ fetch<T = unknown>(url: string, opt?: FetcherOptions<T>): Promise<T>;
34
41
  /**
35
42
  * Returns FetcherResponse.
36
43
  * Never throws, returns `err` property in the response instead.
37
44
  * Use this method instead of `throwHttpErrors: false` or try-catching.
38
45
  */
39
- doFetch<T = unknown>(url: string, rawOpt?: FetcherOptions): Promise<FetcherResponse<T>>;
46
+ doFetch<T = unknown>(url: string, opt?: FetcherOptions<T>): Promise<FetcherResponse<T>>;
47
+ doFetchRequest<T = unknown>(req: FetcherRequest<T>): Promise<FetcherResponse<T>>;
40
48
  private onOkResponse;
41
49
  /**
42
50
  * This method exists to be able to easily mock it.
@@ -77,6 +77,19 @@ class Fetcher {
77
77
  static create(cfg = {}) {
78
78
  return new Fetcher(cfg);
79
79
  }
80
+ // mode=readableStream
81
+ /**
82
+ * Returns raw fetchResponse.body, which is a ReadableStream<Uint8Array>
83
+ *
84
+ * More on streams and Node interop:
85
+ * https://css-tricks.com/web-streams-everywhere-and-fetch-for-node-js/
86
+ */
87
+ async getReadableStream(url, opt) {
88
+ return await this.fetch(url, {
89
+ mode: 'readableStream',
90
+ ...opt,
91
+ });
92
+ }
80
93
  async fetch(url, opt) {
81
94
  const res = await this.doFetch(url, opt);
82
95
  if (res.err) {
@@ -91,9 +104,12 @@ class Fetcher {
91
104
  * Never throws, returns `err` property in the response instead.
92
105
  * Use this method instead of `throwHttpErrors: false` or try-catching.
93
106
  */
94
- async doFetch(url, rawOpt = {}) {
107
+ async doFetch(url, opt = {}) {
108
+ const req = this.normalizeOptions(url, opt);
109
+ return await this.doFetchRequest(req);
110
+ }
111
+ async doFetchRequest(req) {
95
112
  const { logger } = this.cfg;
96
- const req = this.normalizeOptions(url, rawOpt);
97
113
  const { timeoutSeconds, init: { method }, } = req;
98
114
  // setup timeout
99
115
  let timeout;
@@ -104,7 +120,7 @@ class Fetcher {
104
120
  abortController.abort(`timeout of ${timeoutSeconds} sec`);
105
121
  }, timeoutSeconds * 1000);
106
122
  }
107
- for await (const hook of this.cfg.hooks.beforeRequest || []) {
123
+ for (const hook of this.cfg.hooks.beforeRequest || []) {
108
124
  await hook(req);
109
125
  }
110
126
  const isFullUrl = req.url.includes('://');
@@ -121,7 +137,7 @@ class Fetcher {
121
137
  signature,
122
138
  };
123
139
  while (!res.retryStatus.retryStopped) {
124
- const started = Date.now();
140
+ req.started = Date.now();
125
141
  if (this.cfg.logRequest) {
126
142
  const { retryAttempt } = res.retryStatus;
127
143
  logger.log([' >>', signature, retryAttempt && `try#${retryAttempt + 1}/${req.retry.count + 1}`]
@@ -144,19 +160,25 @@ class Fetcher {
144
160
  }
145
161
  res.statusFamily = this.getStatusFamily(res);
146
162
  if (res.fetchResponse?.ok) {
147
- await this.onOkResponse(res, started, timeout);
163
+ await this.onOkResponse(res, timeout);
148
164
  }
149
165
  else {
150
166
  // !res.ok
151
- await this.onNotOkResponse(res, started, timeout);
167
+ await this.onNotOkResponse(res, timeout);
152
168
  }
153
169
  }
154
- for await (const hook of this.cfg.hooks.afterResponse || []) {
170
+ for (const hook of this.cfg.hooks.afterResponse || []) {
155
171
  await hook(res);
156
172
  }
173
+ if (req.paginate && res.ok) {
174
+ const proceed = await req.paginate(req, res);
175
+ if (proceed) {
176
+ return await this.doFetchRequest(req);
177
+ }
178
+ }
157
179
  return res;
158
180
  }
159
- async onOkResponse(res, started, timeout) {
181
+ async onOkResponse(res, timeout) {
160
182
  const { req } = res;
161
183
  const { mode } = res.req;
162
184
  if (mode === 'json') {
@@ -179,7 +201,7 @@ class Fetcher {
179
201
  // } satisfies HttpRequestErrorData)
180
202
  res.err = (0, error_util_1._anyToError)(err);
181
203
  res.ok = false;
182
- return await this.onNotOkResponse(res, started, timeout);
204
+ return await this.onNotOkResponse(res, timeout);
183
205
  }
184
206
  }
185
207
  else {
@@ -202,6 +224,14 @@ class Fetcher {
202
224
  else if (mode === 'blob') {
203
225
  res.body = res.fetchResponse.body ? await res.fetchResponse.blob() : {};
204
226
  }
227
+ else if (mode === 'readableStream') {
228
+ res.body = res.fetchResponse.body;
229
+ if (res.body === null) {
230
+ res.err = new Error(`fetchResponse.body is null`);
231
+ res.ok = false;
232
+ return await this.onNotOkResponse(res, timeout);
233
+ }
234
+ }
205
235
  clearTimeout(timeout);
206
236
  res.retryStatus.retryStopped = true;
207
237
  // res.err can happen on JSON.parse error
@@ -213,7 +243,7 @@ class Fetcher {
213
243
  res.fetchResponse.status,
214
244
  res.signature,
215
245
  retryAttempt && `try#${retryAttempt + 1}/${req.retry.count + 1}`,
216
- (0, time_util_1._since)(started),
246
+ (0, time_util_1._since)(res.req.started),
217
247
  ]
218
248
  .filter(Boolean)
219
249
  .join(' '));
@@ -228,7 +258,7 @@ class Fetcher {
228
258
  async callNativeFetch(url, init) {
229
259
  return await globalThis.fetch(url, init);
230
260
  }
231
- async onNotOkResponse(res, started, timeout) {
261
+ async onNotOkResponse(res, timeout) {
232
262
  clearTimeout(timeout);
233
263
  let cause;
234
264
  if (res.err) {
@@ -254,7 +284,7 @@ class Fetcher {
254
284
  requestBaseUrl: this.cfg.baseUrl || null,
255
285
  requestMethod: res.req.init.method,
256
286
  requestSignature: res.signature,
257
- requestDuration: Date.now() - started,
287
+ requestDuration: Date.now() - res.req.started,
258
288
  }), cause);
259
289
  await this.processRetry(res);
260
290
  }
@@ -263,7 +293,7 @@ class Fetcher {
263
293
  if (!this.shouldRetry(res)) {
264
294
  retryStatus.retryStopped = true;
265
295
  }
266
- for await (const hook of this.cfg.hooks.beforeRetry || []) {
296
+ for (const hook of this.cfg.hooks.beforeRetry || []) {
267
297
  await hook(res);
268
298
  }
269
299
  const { count, timeoutMultiplier, timeoutMax } = res.req.retry;
@@ -272,6 +302,22 @@ class Fetcher {
272
302
  }
273
303
  if (retryStatus.retryStopped)
274
304
  return;
305
+ // Here we know that more retries will be attempted
306
+ // We don't log "last error", because it will be thrown and logged by consumer,
307
+ // but we should log all previous errors, otherwise they are lost.
308
+ // Here is the right place where we know it's not the "last error"
309
+ if (res.err) {
310
+ const { retryAttempt } = retryStatus;
311
+ this.cfg.logger.error([
312
+ ' <<',
313
+ res.fetchResponse?.status || 0,
314
+ res.signature,
315
+ `try#${retryAttempt + 1}/${count + 1}`,
316
+ (0, time_util_1._since)(res.req.started),
317
+ ]
318
+ .filter(Boolean)
319
+ .join(' '), res.err.cause || res.err);
320
+ }
275
321
  retryStatus.retryAttempt++;
276
322
  retryStatus.retryTimeout = (0, number_util_1._clamp)(retryStatus.retryTimeout * timeoutMultiplier, 0, timeoutMax);
277
323
  const noise = Math.random() * 500;
@@ -372,6 +418,7 @@ class Fetcher {
372
418
  normalizeOptions(url, opt) {
373
419
  const { timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode, jsonReviver, } = this.cfg;
374
420
  const req = {
421
+ started: Date.now(),
375
422
  mode,
376
423
  url,
377
424
  timeoutSeconds,
@@ -1,14 +1,14 @@
1
1
  import type { CommonLogger } from '../log/commonLogger';
2
2
  import type { Promisable } from '../typeFest';
3
- import type { Reviver } from '../types';
3
+ import type { Reviver, UnixTimestampMillisNumber } from '../types';
4
4
  import type { HttpMethod, HttpStatusFamily } from './http.model';
5
- export interface FetcherNormalizedCfg extends Required<FetcherCfg>, FetcherRequest {
5
+ export interface FetcherNormalizedCfg extends Required<FetcherCfg>, Omit<FetcherRequest, 'started'> {
6
6
  logger: CommonLogger;
7
7
  searchParams: Record<string, any>;
8
8
  }
9
- export type FetcherBeforeRequestHook = (req: FetcherRequest) => Promisable<void>;
10
- export type FetcherAfterResponseHook = (res: FetcherResponse) => Promisable<void>;
11
- export type FetcherBeforeRetryHook = (res: FetcherResponse) => Promisable<void>;
9
+ export type FetcherBeforeRequestHook = <BODY = unknown>(req: FetcherRequest<BODY>) => Promisable<void>;
10
+ export type FetcherAfterResponseHook = <BODY = unknown>(res: FetcherResponse<BODY>) => Promisable<void>;
11
+ export type FetcherBeforeRetryHook = <BODY = unknown>(res: FetcherResponse<BODY>) => Promisable<void>;
12
12
  export interface FetcherCfg {
13
13
  /**
14
14
  * Should **not** contain trailing slash.
@@ -77,7 +77,7 @@ export interface FetcherRetryOptions {
77
77
  timeoutMax: number;
78
78
  timeoutMultiplier: number;
79
79
  }
80
- export interface FetcherRequest extends Omit<FetcherOptions, 'method' | 'headers' | 'baseUrl'> {
80
+ export interface FetcherRequest<BODY = unknown> extends Omit<FetcherOptions<BODY>, 'method' | 'headers' | 'baseUrl'> {
81
81
  url: string;
82
82
  init: RequestInitNormalized;
83
83
  mode: FetcherMode;
@@ -87,8 +87,9 @@ export interface FetcherRequest extends Omit<FetcherOptions, 'method' | 'headers
87
87
  retryPost: boolean;
88
88
  retry4xx: boolean;
89
89
  retry5xx: boolean;
90
+ started: UnixTimestampMillisNumber;
90
91
  }
91
- export interface FetcherOptions {
92
+ export interface FetcherOptions<BODY = unknown> {
92
93
  method?: HttpMethod;
93
94
  baseUrl?: string;
94
95
  throwHttpErrors?: boolean;
@@ -134,6 +135,18 @@ export interface FetcherOptions {
134
135
  */
135
136
  retry5xx?: boolean;
136
137
  jsonReviver?: Reviver;
138
+ /**
139
+ * Allows to walk over multiple pages of results.
140
+ * Paginate take a function.
141
+ * Function has access to FetcherRequest and FetcherResponse
142
+ * and has to make a decision to continue pagination or not.
143
+ * Return true to continue, false otherwise.
144
+ * If continue - it is expected to modify/mutate the FetcherRequest, as it will be used
145
+ * to request the next page.
146
+ *
147
+ * @experimental
148
+ */
149
+ paginate?: (req: FetcherRequest<BODY>, res: FetcherSuccessResponse<BODY>) => Promisable<boolean>;
137
150
  }
138
151
  export type RequestInitNormalized = Omit<RequestInit, 'method' | 'headers'> & {
139
152
  method: HttpMethod;
@@ -160,4 +173,4 @@ export interface FetcherErrorResponse<BODY = unknown> {
160
173
  signature: string;
161
174
  }
162
175
  export type FetcherResponse<BODY = unknown> = FetcherSuccessResponse<BODY> | FetcherErrorResponse<BODY>;
163
- export type FetcherMode = 'json' | 'text' | 'void' | 'arrayBuffer' | 'blob';
176
+ export type FetcherMode = 'json' | 'text' | 'void' | 'arrayBuffer' | 'blob' | 'readableStream';
@@ -114,7 +114,6 @@ exports._mapValues = _mapValues;
114
114
  * Does not support `mutate` flag.
115
115
  */
116
116
  function _mapKeys(obj, mapper) {
117
- // eslint-disable-next-line unicorn/prefer-object-from-entries
118
117
  return Object.entries(obj).reduce((map, [k, v]) => {
119
118
  map[mapper(k, v, obj)] = v;
120
119
  return map;
@@ -8,7 +8,6 @@ const __1 = require("..");
8
8
  function _sortObjectDeep(o) {
9
9
  // array
10
10
  if (Array.isArray(o)) {
11
- // eslint-disable-next-line unicorn/no-array-callback-reference
12
11
  return o.map(_sortObjectDeep);
13
12
  }
14
13
  if ((0, __1._isObject)(o)) {
@@ -11,8 +11,8 @@ import { AnyFunction } from '../types';
11
11
  * @experimental
12
12
  */
13
13
  export declare class Abortable {
14
- onAbort?: AnyFunction<any> | undefined;
15
- constructor(onAbort?: AnyFunction<any> | undefined);
14
+ onAbort?: AnyFunction | undefined;
15
+ constructor(onAbort?: AnyFunction | undefined);
16
16
  aborted: boolean;
17
17
  abort(): void;
18
18
  clear(): void;
@@ -51,7 +51,7 @@ async function pMap(iterable, mapper, opt = {}) {
51
51
  // Special cases that are able to preserve async stack traces
52
52
  if (concurrency === 1) {
53
53
  // Special case for concurrency == 1
54
- for await (const item of items) {
54
+ for (const item of items) {
55
55
  try {
56
56
  const r = await mapper(item, currentIndex++);
57
57
  if (r === __1.END)
@@ -59,7 +59,6 @@ function _leven(first, second) {
59
59
  for (index = 0; index < firstLength; index++) {
60
60
  temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1;
61
61
  temporary = array[index];
62
- // eslint-disable-next-line no-multi-assign
63
62
  result = array[index] =
64
63
  temporary > result
65
64
  ? temporary2 > result
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable unicorn/prefer-string-slice */
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports._nl2br = exports._replaceAll = exports._substringBetweenLast = exports._substringAfterLast = exports._substringAfter = exports._substringBeforeLast = exports._substringBefore = exports._truncateMiddle = exports._truncate = exports._removeWhitespace = exports._split = exports._lowerFirst = exports._upperFirst = exports._capitalize = void 0;
5
4
  /**
@@ -17,7 +17,7 @@ export declare namespace is {
17
17
  var bigint: (value: unknown) => value is bigint;
18
18
  var function_: (value: unknown) => value is Function;
19
19
  var null_: (value: unknown) => value is null;
20
- var class_: (value: unknown) => value is Class<any>;
20
+ var class_: (value: unknown) => value is Class;
21
21
  var boolean: (value: unknown) => value is boolean;
22
22
  var symbol: (value: unknown) => value is symbol;
23
23
  var numericString: (value: unknown) => value is string;
package/dist/vendor/is.js CHANGED
@@ -63,7 +63,6 @@ const primitiveTypeNames = [
63
63
  function isPrimitiveTypeName(name) {
64
64
  return primitiveTypeNames.includes(name);
65
65
  }
66
- // eslint-disable-next-line @typescript-eslint/ban-types
67
66
  function isOfType(type) {
68
67
  return (value) => typeof value === type;
69
68
  }
@@ -126,7 +125,6 @@ is.string = isOfType('string');
126
125
  const isNumberType = isOfType('number');
127
126
  is.number = (value) => isNumberType(value) && !is.nan(value);
128
127
  is.bigint = isOfType('bigint');
129
- // eslint-disable-next-line @typescript-eslint/ban-types
130
128
  is.function_ = isOfType('function');
131
129
  is.null_ = (value) => value === null;
132
130
  is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
@@ -155,7 +153,6 @@ is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
155
153
  is.generatorFunction = isObjectOfType('GeneratorFunction');
156
154
  is.asyncGeneratorFunction = (value) => getObjectType(value) === 'AsyncGeneratorFunction';
157
155
  is.asyncFunction = (value) => getObjectType(value) === 'AsyncFunction';
158
- // eslint-disable-next-line no-prototype-builtins, @typescript-eslint/ban-types
159
156
  is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
160
157
  is.regExp = isObjectOfType('RegExp');
161
158
  is.date = isObjectOfType('Date');
@@ -185,7 +182,7 @@ is.urlString = (value) => {
185
182
  return false;
186
183
  }
187
184
  try {
188
- new URL(value); // eslint-disable-line no-new
185
+ new URL(value);
189
186
  return true;
190
187
  }
191
188
  catch {
@@ -344,7 +341,6 @@ exports.assert = {
344
341
  string: (value) => assertType(is.string(value), 'string', value),
345
342
  number: (value) => assertType(is.number(value), 'number', value),
346
343
  bigint: (value) => assertType(is.bigint(value), 'bigint', value),
347
- // eslint-disable-next-line @typescript-eslint/ban-types
348
344
  function_: (value) => assertType(is.function_(value), 'Function', value),
349
345
  null_: (value) => assertType(is.null_(value), 'null', value),
350
346
  class_: (value) => assertType(is.class_(value), AssertionTypeDescription.class_, value),
@@ -369,9 +365,7 @@ exports.assert = {
369
365
  promise: (value) => assertType(is.promise(value), 'Promise', value),
370
366
  generatorFunction: (value) => assertType(is.generatorFunction(value), 'GeneratorFunction', value),
371
367
  asyncGeneratorFunction: (value) => assertType(is.asyncGeneratorFunction(value), 'AsyncGeneratorFunction', value),
372
- // eslint-disable-next-line @typescript-eslint/ban-types
373
368
  asyncFunction: (value) => assertType(is.asyncFunction(value), 'AsyncFunction', value),
374
- // eslint-disable-next-line @typescript-eslint/ban-types
375
369
  boundFunction: (value) => assertType(is.boundFunction(value), 'Function', value),
376
370
  regExp: (value) => assertType(is.regExp(value), 'RegExp', value),
377
371
  date: (value) => assertType(is.date(value), 'Date', value),
@@ -134,7 +134,7 @@ export function _groupBy(items, mapper) {
134
134
  export function _sortBy(items, mapper, mutate = false, descending = false) {
135
135
  const mod = descending ? -1 : 1;
136
136
  return (mutate ? items : [...items]).sort((_a, _b) => {
137
- const [a, b] = [_a, _b].map(mapper); // eslint-disable-line unicorn/no-array-callback-reference
137
+ const [a, b] = [_a, _b].map(mapper);
138
138
  if (typeof a === 'number' && typeof b === 'number')
139
139
  return (a - b) * mod;
140
140
  return String(a).localeCompare(String(b)) * mod;
@@ -144,7 +144,7 @@ export function _sortBy(items, mapper, mutate = false, descending = false) {
144
144
  * Like items.find(), but it tries to find from the END of the array.
145
145
  */
146
146
  export function _findLast(items, predicate) {
147
- return [...items].reverse().find(predicate); // eslint-disable-line unicorn/no-array-callback-reference
147
+ return [...items].reverse().find(predicate);
148
148
  }
149
149
  export function _takeWhile(items, predicate) {
150
150
  let proceed = true;
@@ -2,7 +2,6 @@ import { _assert } from '../error/assert';
2
2
  import { LocalTime } from './localTime';
3
3
  const MDAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
4
4
  const DATE_REGEX = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
5
- /* eslint-disable no-dupe-class-members */
6
5
  /**
7
6
  * @experimental
8
7
  */
@@ -17,7 +17,6 @@ const SECONDS_IN_DAY = 86400;
17
17
  // const MILLISECONDS_IN_DAY = 86400000
18
18
  // const MILLISECONDS_IN_MINUTE = 60000
19
19
  const VALID_DAYS_OF_WEEK = new Set([1, 2, 3, 4, 5, 6, 7]);
20
- /* eslint-disable no-dupe-class-members */
21
20
  /**
22
21
  * @experimental
23
22
  */
@@ -10,7 +10,6 @@ import { _getTargetMethodSignature } from './decorator.util';
10
10
  *
11
11
  * @experimental
12
12
  */
13
- // eslint-disable-next-line @typescript-eslint/naming-convention
14
13
  export function _createPromiseDecorator(cfg, decoratorParams = {}) {
15
14
  const { decoratorName } = cfg;
16
15
  return function decoratorFunction(target, propertyKey, pd) {