@naturalcycles/js-lib 15.40.0 → 15.40.2

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.
@@ -99,12 +99,10 @@ export class BotDetectionService {
99
99
  let cdpCheck1 = false;
100
100
  try {
101
101
  /* eslint-disable */
102
- // biome-ignore lint/suspicious/useErrorMessage: ok
103
102
  const e = new window.Error();
104
103
  window.Object.defineProperty(e, 'stack', {
105
104
  configurable: false,
106
105
  enumerable: false,
107
- // biome-ignore lint/complexity/useArrowFunction: ok
108
106
  get: function () {
109
107
  cdpCheck1 = true;
110
108
  return '';
package/dist/env.js CHANGED
@@ -14,6 +14,6 @@ export function isServerSide() {
14
14
  * Will return `false` in Node.js.
15
15
  */
16
16
  export function isClientSide() {
17
- // eslint-disable-next-line unicorn/prefer-global-this
17
+ // oxlint-disable-next-line unicorn/prefer-global-this
18
18
  return typeof window !== 'undefined' && !!window?.document;
19
19
  }
@@ -55,7 +55,7 @@ export declare function _isErrorLike(o: any): o is ErrorLike;
55
55
  * })
56
56
  * }
57
57
  */
58
- export declare function _errorDataAppend<ERR>(err: ERR, data?: ErrorData): ERR;
58
+ export declare function _errorDataAppend<ERR, OUT extends Error = ERR extends Error ? ERR : Error>(err: ERR, data?: ErrorData): OUT;
59
59
  export interface AppErrorComponents<DATA_TYPE extends ErrorData = ErrorData> {
60
60
  message: string;
61
61
  name?: string;
@@ -22,10 +22,9 @@ export function _anyToError(o, errorClass = Error, errorData) {
22
22
  }
23
23
  if (errorData) {
24
24
  ;
25
- e.data = {
26
- ...e.data,
27
- ...errorData,
28
- };
25
+ e.data ||= {};
26
+ // Using Object.assign instead of ...data to not override err.data's non-enumerable properties
27
+ Object.assign(e.data, errorData);
29
28
  }
30
29
  return e;
31
30
  }
@@ -209,10 +208,7 @@ export function _isErrorLike(o) {
209
208
  export function _errorDataAppend(err, data) {
210
209
  if (!data)
211
210
  return err;
212
- err.data ||= {}; // create err.data if it doesn't exist
213
- // Using Object.assign instead of ...data to not override err.data's non-enumerable properties
214
- Object.assign(err.data, data);
215
- return err;
211
+ return _anyToError(err, undefined, data);
216
212
  }
217
213
  /**
218
214
  * Base class for all our (not system) errors.
@@ -16,7 +16,7 @@ export declare class Fetcher {
16
16
  *
17
17
  * Version is to be incremented every time a difference in behaviour (or a bugfix) is done.
18
18
  */
19
- private static readonly VERSION;
19
+ static readonly VERSION = 3;
20
20
  /**
21
21
  * userAgent is statically exposed as Fetcher.userAgent.
22
22
  * It can be modified globally, and will be used (read) at the start of every request.
@@ -32,7 +32,7 @@ export class Iterable2 {
32
32
  }
33
33
  }
34
34
  some(cb) {
35
- // eslint-disable-next-line unicorn/prefer-array-some
35
+ // oxlint-disable-next-line unicorn/prefer-array-some
36
36
  return !!this.find(cb);
37
37
  }
38
38
  every(cb) {
@@ -40,7 +40,7 @@ export function _isBetween(x, min, max, incl) {
40
40
  return true;
41
41
  }
42
42
  export function _clamp(x, minIncl, maxIncl) {
43
- // eslint-disable-next-line unicorn/prefer-math-min-max
43
+ // oxlint-disable-next-line unicorn/prefer-math-min-max
44
44
  return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x;
45
45
  }
46
46
  /**
@@ -49,7 +49,7 @@ export function hashCode(s) {
49
49
  let i = 0;
50
50
  const len = s.length;
51
51
  while (i < len) {
52
- // eslint-disable-next-line unicorn/prefer-math-trunc, unicorn/prefer-code-point
52
+ // oxlint-disable-next-line unicorn/prefer-math-trunc, unicorn/prefer-code-point
53
53
  hash = ((hash << 5) - hash + s.charCodeAt(i++)) << 0;
54
54
  }
55
55
  return hash + 2147483647 + 1;
@@ -1,7 +1,6 @@
1
1
  const array = [];
2
2
  const characterCodeCache = [];
3
- /* eslint-disable unicorn/prefer-code-point */
4
- // oxlint-disable no-bitwise
3
+ // oxlint-disable no-bitwise, unicorn/prefer-code-point
5
4
  /**
6
5
  * Modified version of: https://github.com/sindresorhus/leven/
7
6
  *
@@ -1,9 +1,8 @@
1
1
  // from: https://github.com/lodash/lodash/blob/master/words.js
2
- /* eslint-disable */
3
2
  import { unicodeWords } from './unicodeWords.js';
3
+ // oxlint-disable
4
4
  const hasUnicodeWord = RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/);
5
5
  /** Used to match words composed of alphanumeric characters. */
6
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ok
7
6
  const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
8
7
  function asciiWords(s) {
9
8
  return s.match(reAsciiWord);
@@ -61,5 +61,6 @@ function decamelize(s) {
61
61
  function escapeStringRegexp(s) {
62
62
  // Escape characters with special meaning either inside or outside character sets.
63
63
  // Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
64
+ // oxlint-disable-next-line unicorn/escape-case, unicorn/no-hex-escape
64
65
  return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, String.raw `\$&`).replaceAll('-', String.raw `\x2d`);
65
66
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.40.0",
4
+ "version": "15.40.2",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "undici": "^7",
@@ -132,12 +132,10 @@ export class BotDetectionService {
132
132
  let cdpCheck1 = false
133
133
  try {
134
134
  /* eslint-disable */
135
- // biome-ignore lint/suspicious/useErrorMessage: ok
136
135
  const e = new window.Error()
137
136
  window.Object.defineProperty(e, 'stack', {
138
137
  configurable: false,
139
138
  enumerable: false,
140
- // biome-ignore lint/complexity/useArrowFunction: ok
141
139
  get: function () {
142
140
  cdpCheck1 = true
143
141
  return ''
package/src/env.ts CHANGED
@@ -15,6 +15,6 @@ export function isServerSide(): boolean {
15
15
  * Will return `false` in Node.js.
16
16
  */
17
17
  export function isClientSide(): boolean {
18
- // eslint-disable-next-line unicorn/prefer-global-this
18
+ // oxlint-disable-next-line unicorn/prefer-global-this
19
19
  return typeof window !== 'undefined' && !!window?.document
20
20
  }
@@ -36,10 +36,9 @@ export function _anyToError<ERROR_TYPE extends Error = Error>(
36
36
  }
37
37
 
38
38
  if (errorData) {
39
- ;(e as any).data = {
40
- ...(e as any).data,
41
- ...errorData,
42
- }
39
+ ;(e as any).data ||= {}
40
+ // Using Object.assign instead of ...data to not override err.data's non-enumerable properties
41
+ Object.assign((e as any).data, errorData)
43
42
  }
44
43
 
45
44
  return e
@@ -266,12 +265,12 @@ export function _isErrorLike(o: any): o is ErrorLike {
266
265
  * })
267
266
  * }
268
267
  */
269
- export function _errorDataAppend<ERR>(err: ERR, data?: ErrorData): ERR {
270
- if (!data) return err
271
- ;(err as any).data ||= {} // create err.data if it doesn't exist
272
- // Using Object.assign instead of ...data to not override err.data's non-enumerable properties
273
- Object.assign((err as any).data, data)
274
- return err
268
+ export function _errorDataAppend<ERR, OUT extends Error = ERR extends Error ? ERR : Error>(
269
+ err: ERR,
270
+ data?: ErrorData,
271
+ ): OUT {
272
+ if (!data) return err as any
273
+ return _anyToError<OUT>(err, undefined, data)
275
274
  }
276
275
 
277
276
  export interface AppErrorComponents<DATA_TYPE extends ErrorData = ErrorData> {
@@ -67,7 +67,7 @@ export class Fetcher {
67
67
  *
68
68
  * Version is to be incremented every time a difference in behaviour (or a bugfix) is done.
69
69
  */
70
- private static readonly VERSION = 3
70
+ static readonly VERSION = 3
71
71
  /**
72
72
  * userAgent is statically exposed as Fetcher.userAgent.
73
73
  * It can be modified globally, and will be used (read) at the start of every request.
@@ -36,7 +36,7 @@ export class Iterable2<T> implements Iterable<T> {
36
36
  }
37
37
 
38
38
  some(cb: AbortablePredicate<T>): boolean {
39
- // eslint-disable-next-line unicorn/prefer-array-some
39
+ // oxlint-disable-next-line unicorn/prefer-array-some
40
40
  return !!this.find(cb)
41
41
  }
42
42
 
@@ -33,7 +33,7 @@ import type {
33
33
  } from './jsonSchema.model.js'
34
34
  import { mergeJsonSchemaObjects } from './jsonSchema.util.js'
35
35
 
36
- /* eslint-disable id-blacklist, @typescript-eslint/explicit-module-boundary-types */
36
+ /* eslint-disable id-denylist, @typescript-eslint/explicit-module-boundary-types */
37
37
 
38
38
  export interface JsonSchemaBuilder<T = unknown> {
39
39
  build: () => JsonSchema<T>
@@ -51,7 +51,7 @@ export function _isBetween<T extends number | string>(
51
51
  }
52
52
 
53
53
  export function _clamp(x: number, minIncl: number, maxIncl: number): number {
54
- // eslint-disable-next-line unicorn/prefer-math-min-max
54
+ // oxlint-disable-next-line unicorn/prefer-math-min-max
55
55
  return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x
56
56
  }
57
57
 
@@ -56,7 +56,7 @@ export function hashCode(s: string): Integer {
56
56
  let i = 0
57
57
  const len = s.length
58
58
  while (i < len) {
59
- // eslint-disable-next-line unicorn/prefer-math-trunc, unicorn/prefer-code-point
59
+ // oxlint-disable-next-line unicorn/prefer-math-trunc, unicorn/prefer-code-point
60
60
  hash = ((hash << 5) - hash + s.charCodeAt(i++)) << 0
61
61
  }
62
62
  return hash + 2147483647 + 1
@@ -1,8 +1,7 @@
1
1
  const array: number[] = []
2
2
  const characterCodeCache: number[] = []
3
3
 
4
- /* eslint-disable unicorn/prefer-code-point */
5
- // oxlint-disable no-bitwise
4
+ // oxlint-disable no-bitwise, unicorn/prefer-code-point
6
5
 
7
6
  /**
8
7
  * Modified version of: https://github.com/sindresorhus/leven/
@@ -1,15 +1,14 @@
1
1
  // from: https://github.com/lodash/lodash/blob/master/words.js
2
2
 
3
- /* eslint-disable */
4
-
5
3
  import { unicodeWords } from './unicodeWords.js'
6
4
 
5
+ // oxlint-disable
6
+
7
7
  const hasUnicodeWord = RegExp.prototype.test.bind(
8
8
  /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,
9
9
  )
10
10
 
11
11
  /** Used to match words composed of alphanumeric characters. */
12
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ok
13
12
  const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g
14
13
 
15
14
  function asciiWords(s: string): RegExpMatchArray | null {
@@ -102,5 +102,6 @@ function decamelize(s: string): string {
102
102
  function escapeStringRegexp(s: string): string {
103
103
  // Escape characters with special meaning either inside or outside character sets.
104
104
  // Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
105
+ // oxlint-disable-next-line unicorn/escape-case, unicorn/no-hex-escape
105
106
  return s.replaceAll(/[|\\{}()[\]^$+*?.]/g, String.raw`\$&`).replaceAll('-', String.raw`\x2d`)
106
107
  }