@naturalcycles/js-lib 15.40.1 → 15.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/bot.js +0 -2
- package/dist/env.js +1 -1
- package/dist/error/error.util.d.ts +1 -1
- package/dist/error/error.util.js +4 -8
- package/dist/iter/iterable2.js +1 -1
- package/dist/json-schema/jsonSchemaBuilder.d.ts +7 -7
- package/dist/json-schema/jsonSchemaBuilder.js +20 -16
- package/dist/number/number.util.js +1 -1
- package/dist/promise/pTimeout.js +1 -0
- package/dist/string/hash.util.js +1 -1
- package/dist/string/leven.js +1 -2
- package/dist/string/lodash/words.js +1 -2
- package/dist/string/slugify.js +1 -0
- package/package.json +1 -1
- package/src/browser/bot.ts +0 -2
- package/src/env.ts +1 -1
- package/src/error/error.util.ts +9 -10
- package/src/iter/iterable2.ts +1 -1
- package/src/json-schema/jsonSchemaBuilder.ts +28 -21
- package/src/number/number.util.ts +1 -1
- package/src/promise/pTimeout.ts +1 -0
- package/src/string/hash.util.ts +1 -1
- package/src/string/leven.ts +1 -2
- package/src/string/lodash/words.ts +2 -3
- package/src/string/slugify.ts +1 -0
package/dist/browser/bot.js
CHANGED
|
@@ -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
|
-
//
|
|
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):
|
|
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;
|
package/dist/error/error.util.js
CHANGED
|
@@ -22,10 +22,9 @@ export function _anyToError(o, errorClass = Error, errorData) {
|
|
|
22
22
|
}
|
|
23
23
|
if (errorData) {
|
|
24
24
|
;
|
|
25
|
-
e.data
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
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.
|
package/dist/iter/iterable2.js
CHANGED
|
@@ -101,9 +101,10 @@ export declare class JsonSchemaStringBuilder<T extends string = string, Opt exte
|
|
|
101
101
|
languageTag: () => this;
|
|
102
102
|
countryCode: () => this;
|
|
103
103
|
currency: () => this;
|
|
104
|
-
trim
|
|
105
|
-
toLowerCase
|
|
106
|
-
toUpperCase
|
|
104
|
+
trim(trim?: boolean): this;
|
|
105
|
+
toLowerCase(toLowerCase?: boolean): this;
|
|
106
|
+
toUpperCase(toUpperCase?: boolean): this;
|
|
107
|
+
truncate(toLength: number): this;
|
|
107
108
|
branded<B extends string>(): JsonSchemaStringBuilder<B>;
|
|
108
109
|
/**
|
|
109
110
|
* Accepts only the `YYYY-MM-DD` shape from all ISO 8601 variants.
|
|
@@ -115,11 +116,10 @@ export declare class JsonSchemaStringBuilder<T extends string = string, Opt exte
|
|
|
115
116
|
*/
|
|
116
117
|
isoDateTime(): JsonSchemaStringBuilder<IsoDateTime>;
|
|
117
118
|
jwt(): this;
|
|
118
|
-
private transformModify;
|
|
119
119
|
}
|
|
120
120
|
export declare class JsonSchemaObjectBuilder<T extends AnyObject, Opt extends boolean = false> extends JsonSchemaAnyBuilder<T, JsonSchemaObject<T>, Opt> {
|
|
121
121
|
constructor();
|
|
122
|
-
addProperties(props
|
|
122
|
+
addProperties(props?: {
|
|
123
123
|
[k in keyof T]: JsonSchemaBuilder<T[k]>;
|
|
124
124
|
}): this;
|
|
125
125
|
/**
|
|
@@ -144,14 +144,14 @@ export declare class JsonSchemaArrayBuilder<ITEM, Opt extends boolean = false> e
|
|
|
144
144
|
export declare class JsonSchemaTupleBuilder<T extends any[]> extends JsonSchemaAnyBuilder<T, JsonSchemaTuple<T>> {
|
|
145
145
|
constructor(items: JsonSchemaBuilder[]);
|
|
146
146
|
}
|
|
147
|
-
declare function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props
|
|
147
|
+
declare function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(props?: P): JsonSchemaObjectBuilder<{
|
|
148
148
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt> ? Opt extends true ? never : K : never]: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never;
|
|
149
149
|
} & {
|
|
150
150
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt> ? Opt extends true ? K : never : never]?: P[K] extends JsonSchemaAnyBuilder<infer U, any, any> ? U : never;
|
|
151
151
|
} extends infer O ? {
|
|
152
152
|
[K in keyof O]: O[K];
|
|
153
153
|
} : never>;
|
|
154
|
-
declare function object<T extends AnyObject>(props
|
|
154
|
+
declare function object<T extends AnyObject>(props?: {
|
|
155
155
|
[K in keyof T]: JsonSchemaAnyBuilder<T[K]>;
|
|
156
156
|
}): JsonSchemaObjectBuilder<T>;
|
|
157
157
|
export {};
|
|
@@ -54,9 +54,7 @@ export const j = {
|
|
|
54
54
|
});
|
|
55
55
|
},
|
|
56
56
|
buffer() {
|
|
57
|
-
return new JsonSchemaAnyBuilder({
|
|
58
|
-
instanceof: 'Buffer',
|
|
59
|
-
});
|
|
57
|
+
return new JsonSchemaAnyBuilder({ instanceof: 'Buffer' });
|
|
60
58
|
},
|
|
61
59
|
// number types
|
|
62
60
|
number() {
|
|
@@ -144,7 +142,7 @@ export class JsonSchemaAnyBuilder {
|
|
|
144
142
|
return this;
|
|
145
143
|
}
|
|
146
144
|
instanceof(of) {
|
|
147
|
-
this.schema
|
|
145
|
+
Object.assign(this.schema, { type: 'object', instanceof: of });
|
|
148
146
|
return this;
|
|
149
147
|
}
|
|
150
148
|
optional(optional = true) {
|
|
@@ -280,9 +278,22 @@ export class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
|
|
|
280
278
|
languageTag = () => this.format('languageTag');
|
|
281
279
|
countryCode = () => this.format('countryCode');
|
|
282
280
|
currency = () => this.format('currency');
|
|
283
|
-
trim
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
trim(trim = true) {
|
|
282
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, trim } });
|
|
283
|
+
return this;
|
|
284
|
+
}
|
|
285
|
+
toLowerCase(toLowerCase = true) {
|
|
286
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, toLowerCase } });
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
toUpperCase(toUpperCase = true) {
|
|
290
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, toUpperCase } });
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
truncate(toLength) {
|
|
294
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, truncate: toLength } });
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
286
297
|
branded() {
|
|
287
298
|
return this;
|
|
288
299
|
}
|
|
@@ -302,15 +313,6 @@ export class JsonSchemaStringBuilder extends JsonSchemaAnyBuilder {
|
|
|
302
313
|
jwt() {
|
|
303
314
|
return this.regex(JWT_REGEX);
|
|
304
315
|
}
|
|
305
|
-
transformModify(t, add) {
|
|
306
|
-
if (add) {
|
|
307
|
-
this.schema.transform = _uniq([...(this.schema.transform || []), t]);
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
this.schema.transform = this.schema.transform?.filter(s => s !== t);
|
|
311
|
-
}
|
|
312
|
-
return this;
|
|
313
|
-
}
|
|
314
316
|
}
|
|
315
317
|
export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
316
318
|
constructor() {
|
|
@@ -322,6 +324,8 @@ export class JsonSchemaObjectBuilder extends JsonSchemaAnyBuilder {
|
|
|
322
324
|
});
|
|
323
325
|
}
|
|
324
326
|
addProperties(props) {
|
|
327
|
+
if (!props)
|
|
328
|
+
return this;
|
|
325
329
|
Object.entries(props).forEach(([k, builder]) => {
|
|
326
330
|
const schema = builder.build();
|
|
327
331
|
if (!schema.optionalField) {
|
|
@@ -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
|
-
//
|
|
43
|
+
// oxlint-disable-next-line unicorn/prefer-math-min-max
|
|
44
44
|
return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x;
|
|
45
45
|
}
|
|
46
46
|
/**
|
package/dist/promise/pTimeout.js
CHANGED
|
@@ -44,6 +44,7 @@ export async function pTimeout(fn, opt) {
|
|
|
44
44
|
_typeCast(err);
|
|
45
45
|
// keep original stack
|
|
46
46
|
err.stack = fakeError.stack.replace('Error: TimeoutError', err.name + ': ' + err.message);
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
47
48
|
reject(_errorDataAppend(err, opt.errorData));
|
|
48
49
|
}
|
|
49
50
|
return;
|
package/dist/string/hash.util.js
CHANGED
|
@@ -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
|
-
//
|
|
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;
|
package/dist/string/leven.js
CHANGED
|
@@ -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);
|
package/dist/string/slugify.js
CHANGED
|
@@ -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
package/src/browser/bot.ts
CHANGED
|
@@ -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
|
-
//
|
|
18
|
+
// oxlint-disable-next-line unicorn/prefer-global-this
|
|
19
19
|
return typeof window !== 'undefined' && !!window?.document
|
|
20
20
|
}
|
package/src/error/error.util.ts
CHANGED
|
@@ -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
|
-
|
|
41
|
-
|
|
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
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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> {
|
package/src/iter/iterable2.ts
CHANGED
|
@@ -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-
|
|
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>
|
|
@@ -101,9 +101,7 @@ export const j = {
|
|
|
101
101
|
})
|
|
102
102
|
},
|
|
103
103
|
buffer() {
|
|
104
|
-
return new JsonSchemaAnyBuilder<Buffer, JsonSchemaAny<Buffer>>({
|
|
105
|
-
instanceof: 'Buffer',
|
|
106
|
-
})
|
|
104
|
+
return new JsonSchemaAnyBuilder<Buffer, JsonSchemaAny<Buffer>>({ instanceof: 'Buffer' })
|
|
107
105
|
},
|
|
108
106
|
|
|
109
107
|
// number types
|
|
@@ -215,7 +213,7 @@ export class JsonSchemaAnyBuilder<
|
|
|
215
213
|
}
|
|
216
214
|
|
|
217
215
|
instanceof(of: string): this {
|
|
218
|
-
this.schema
|
|
216
|
+
Object.assign(this.schema, { type: 'object', instanceof: of })
|
|
219
217
|
return this
|
|
220
218
|
}
|
|
221
219
|
|
|
@@ -395,9 +393,25 @@ export class JsonSchemaStringBuilder<
|
|
|
395
393
|
countryCode = (): this => this.format('countryCode')
|
|
396
394
|
currency = (): this => this.format('currency')
|
|
397
395
|
|
|
398
|
-
trim
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
trim(trim = true): this {
|
|
397
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, trim } })
|
|
398
|
+
return this
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
toLowerCase(toLowerCase = true): this {
|
|
402
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, toLowerCase } })
|
|
403
|
+
return this
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
toUpperCase(toUpperCase = true): this {
|
|
407
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, toUpperCase } })
|
|
408
|
+
return this
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
truncate(toLength: number): this {
|
|
412
|
+
Object.assign(this.schema, { transform: { ...this.schema.transform, truncate: toLength } })
|
|
413
|
+
return this
|
|
414
|
+
}
|
|
401
415
|
|
|
402
416
|
branded<B extends string>(): JsonSchemaStringBuilder<B> {
|
|
403
417
|
return this as unknown as JsonSchemaStringBuilder<B>
|
|
@@ -422,15 +436,6 @@ export class JsonSchemaStringBuilder<
|
|
|
422
436
|
return this.regex(JWT_REGEX)
|
|
423
437
|
}
|
|
424
438
|
|
|
425
|
-
private transformModify(t: 'trim' | 'toLowerCase' | 'toUpperCase', add: boolean): this {
|
|
426
|
-
if (add) {
|
|
427
|
-
this.schema.transform = _uniq([...(this.schema.transform || []), t])
|
|
428
|
-
} else {
|
|
429
|
-
this.schema.transform = this.schema.transform?.filter(s => s !== t)
|
|
430
|
-
}
|
|
431
|
-
return this
|
|
432
|
-
}
|
|
433
|
-
|
|
434
439
|
// contentMediaType?: string
|
|
435
440
|
// contentEncoding?: string
|
|
436
441
|
}
|
|
@@ -448,7 +453,9 @@ export class JsonSchemaObjectBuilder<
|
|
|
448
453
|
})
|
|
449
454
|
}
|
|
450
455
|
|
|
451
|
-
addProperties(props
|
|
456
|
+
addProperties(props?: { [k in keyof T]: JsonSchemaBuilder<T[k]> }): this {
|
|
457
|
+
if (!props) return this
|
|
458
|
+
|
|
452
459
|
Object.entries(props).forEach(([k, builder]: [keyof T, JsonSchemaBuilder]) => {
|
|
453
460
|
const schema = builder.build()
|
|
454
461
|
if (!schema.optionalField) {
|
|
@@ -555,7 +562,7 @@ export class JsonSchemaTupleBuilder<T extends any[]> extends JsonSchemaAnyBuilde
|
|
|
555
562
|
}
|
|
556
563
|
|
|
557
564
|
function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(
|
|
558
|
-
props
|
|
565
|
+
props?: P,
|
|
559
566
|
): JsonSchemaObjectBuilder<
|
|
560
567
|
{
|
|
561
568
|
[K in keyof P as P[K] extends JsonSchemaAnyBuilder<any, any, infer Opt>
|
|
@@ -573,10 +580,10 @@ function object<P extends Record<string, JsonSchemaAnyBuilder<any, any, any>>>(
|
|
|
573
580
|
? { [K in keyof O]: O[K] }
|
|
574
581
|
: never
|
|
575
582
|
>
|
|
576
|
-
function object<T extends AnyObject>(props
|
|
583
|
+
function object<T extends AnyObject>(props?: {
|
|
577
584
|
[K in keyof T]: JsonSchemaAnyBuilder<T[K]>
|
|
578
585
|
}): JsonSchemaObjectBuilder<T>
|
|
579
586
|
|
|
580
|
-
function object(props
|
|
587
|
+
function object(props?: any): any {
|
|
581
588
|
return new JsonSchemaObjectBuilder<any>().addProperties(props)
|
|
582
589
|
}
|
|
@@ -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
|
-
//
|
|
54
|
+
// oxlint-disable-next-line unicorn/prefer-math-min-max
|
|
55
55
|
return x <= minIncl ? minIncl : x >= maxIncl ? maxIncl : x
|
|
56
56
|
}
|
|
57
57
|
|
package/src/promise/pTimeout.ts
CHANGED
|
@@ -88,6 +88,7 @@ export async function pTimeout<T>(fn: AnyAsyncFunction<T>, opt: PTimeoutOptions)
|
|
|
88
88
|
_typeCast<Error>(err)
|
|
89
89
|
// keep original stack
|
|
90
90
|
err.stack = fakeError.stack!.replace('Error: TimeoutError', err.name + ': ' + err.message)
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
91
92
|
reject(_errorDataAppend(err, opt.errorData))
|
|
92
93
|
}
|
|
93
94
|
return
|
package/src/string/hash.util.ts
CHANGED
|
@@ -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
|
-
//
|
|
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
|
package/src/string/leven.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const array: number[] = []
|
|
2
2
|
const characterCodeCache: number[] = []
|
|
3
3
|
|
|
4
|
-
|
|
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 {
|
package/src/string/slugify.ts
CHANGED
|
@@ -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
|
}
|