@naturalcycles/js-lib 15.16.0 → 15.16.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abort.js';
2
2
  export * from './array/array.util.js';
3
3
  export * from './array/range.js';
4
+ export * from './bot.model.js';
4
5
  export * from './define.js';
5
6
  export * from './enum.util.js';
6
7
  export * from './env.js';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abort.js';
2
2
  export * from './array/array.util.js';
3
3
  export * from './array/range.js';
4
+ export * from './bot.model.js';
4
5
  export * from './define.js';
5
6
  export * from './enum.util.js';
6
7
  export * from './env.js';
@@ -1,4 +1,3 @@
1
- import type { Primitive } from './types.js';
2
1
  /**
3
2
  Flatten the type output to improve type hints shown in editors.
4
3
  */
@@ -44,54 +43,6 @@ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ?
44
43
  export type Except<ObjectType, KeysType extends keyof ObjectType> = {
45
44
  [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
46
45
  };
47
- /**
48
- Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
49
-
50
- This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
51
-
52
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
53
-
54
- @example
55
- ```
56
- // data.json
57
- {
58
- "foo": ["bar"]
59
- }
60
-
61
- // main.ts
62
- import {ReadonlyDeep} from 'type-fest';
63
- import dataJson = require('./data.json');
64
-
65
- const data: ReadonlyDeep<typeof dataJson> = dataJson;
66
-
67
- export default data;
68
-
69
- // test.ts
70
- import data from './main';
71
-
72
- data.foo.push('bar');
73
- //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
74
- ```
75
-
76
- @category Utilities
77
- */
78
- export type ReadonlyDeep<T> = T extends Primitive | ((...args: any[]) => unknown) ? T : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMapDeep<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? ReadonlySetDeep<ItemType> : T extends object ? ReadonlyObjectDeep<T> : unknown;
79
- /**
80
- Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
81
- */
82
- interface ReadonlyMapDeep<KeyType, ValueType> extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>> {
83
- }
84
- /**
85
- Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
86
- */
87
- interface ReadonlySetDeep<ItemType> extends ReadonlySet<ReadonlyDeep<ItemType>> {
88
- }
89
- /**
90
- Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
91
- */
92
- type ReadonlyObjectDeep<ObjectType extends object> = {
93
- readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>;
94
- };
95
46
  /**
96
47
  * Pick only index signatures from the given object type, leaving out all explicitly defined properties.
97
48
  * This is the counterpart of `OmitIndexSignature`.
package/dist/types.d.ts CHANGED
@@ -343,4 +343,52 @@ export type Promisable<T> = T | PromiseLike<T>;
343
343
  Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
344
344
  */
345
345
  export type Class<T = any> = new (...args: any[]) => T;
346
+ /**
347
+ Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
348
+
349
+ This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
350
+
351
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
352
+
353
+ @example
354
+ ```
355
+ // data.json
356
+ {
357
+ "foo": ["bar"]
358
+ }
359
+
360
+ // main.ts
361
+ import {ReadonlyDeep} from 'type-fest';
362
+ import dataJson = require('./data.json');
363
+
364
+ const data: ReadonlyDeep<typeof dataJson> = dataJson;
365
+
366
+ export default data;
367
+
368
+ // test.ts
369
+ import data from './main';
370
+
371
+ data.foo.push('bar');
372
+ //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
373
+ ```
374
+
375
+ @category Utilities
376
+ */
377
+ export type ReadonlyDeep<T> = T extends Primitive | ((...args: any[]) => unknown) ? T : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMapDeep<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? ReadonlySetDeep<ItemType> : T extends object ? ReadonlyObjectDeep<T> : unknown;
378
+ /**
379
+ Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
380
+ */
381
+ interface ReadonlyMapDeep<KeyType, ValueType> extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>> {
382
+ }
383
+ /**
384
+ Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
385
+ */
386
+ interface ReadonlySetDeep<ItemType> extends ReadonlySet<ReadonlyDeep<ItemType>> {
387
+ }
388
+ /**
389
+ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
390
+ */
391
+ type ReadonlyObjectDeep<ObjectType extends object> = {
392
+ readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>;
393
+ };
346
394
  export {};
package/dist/types.js CHANGED
@@ -64,3 +64,4 @@ export function _typeCast(v) { }
64
64
  * Type-safe Object.assign that checks that part is indeed a Partial<T>
65
65
  */
66
66
  export const _objectAssign = Object.assign;
67
+ /* eslint-enable */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.16.0",
4
+ "version": "15.16.2",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "zod": "^4"
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './abort.js'
2
2
  export * from './array/array.util.js'
3
3
  export * from './array/range.js'
4
+ export * from './bot.model.js'
4
5
  export * from './define.js'
5
6
  export * from './enum.util.js'
6
7
  export * from './env.js'
package/src/typeFest.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  /* eslint-disable */
2
2
 
3
- import type { Primitive } from './types.js'
4
-
5
3
  /**
6
4
  Flatten the type output to improve type hints shown in editors.
7
5
  */
@@ -51,65 +49,6 @@ export type Except<ObjectType, KeysType extends keyof ObjectType> = {
51
49
  [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]
52
50
  }
53
51
 
54
- /**
55
- Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
56
-
57
- This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
58
-
59
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
60
-
61
- @example
62
- ```
63
- // data.json
64
- {
65
- "foo": ["bar"]
66
- }
67
-
68
- // main.ts
69
- import {ReadonlyDeep} from 'type-fest';
70
- import dataJson = require('./data.json');
71
-
72
- const data: ReadonlyDeep<typeof dataJson> = dataJson;
73
-
74
- export default data;
75
-
76
- // test.ts
77
- import data from './main';
78
-
79
- data.foo.push('bar');
80
- //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
81
- ```
82
-
83
- @category Utilities
84
- */
85
- export type ReadonlyDeep<T> = T extends Primitive | ((...args: any[]) => unknown)
86
- ? T
87
- : T extends ReadonlyMap<infer KeyType, infer ValueType>
88
- ? ReadonlyMapDeep<KeyType, ValueType>
89
- : T extends ReadonlySet<infer ItemType>
90
- ? ReadonlySetDeep<ItemType>
91
- : T extends object
92
- ? ReadonlyObjectDeep<T>
93
- : unknown
94
-
95
- /**
96
- Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
97
- */
98
- interface ReadonlyMapDeep<KeyType, ValueType>
99
- extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>> {}
100
-
101
- /**
102
- Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
103
- */
104
- interface ReadonlySetDeep<ItemType> extends ReadonlySet<ReadonlyDeep<ItemType>> {}
105
-
106
- /**
107
- Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
108
- */
109
- type ReadonlyObjectDeep<ObjectType extends object> = {
110
- readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
111
- }
112
-
113
52
  /**
114
53
  * Pick only index signatures from the given object type, leaving out all explicitly defined properties.
115
54
  * This is the counterpart of `OmitIndexSignature`.
package/src/types.ts CHANGED
@@ -443,3 +443,65 @@ export type Promisable<T> = T | PromiseLike<T>
443
443
  Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
444
444
  */
445
445
  export type Class<T = any> = new (...args: any[]) => T
446
+
447
+ /**
448
+ Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
449
+
450
+ This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
451
+
452
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
453
+
454
+ @example
455
+ ```
456
+ // data.json
457
+ {
458
+ "foo": ["bar"]
459
+ }
460
+
461
+ // main.ts
462
+ import {ReadonlyDeep} from 'type-fest';
463
+ import dataJson = require('./data.json');
464
+
465
+ const data: ReadonlyDeep<typeof dataJson> = dataJson;
466
+
467
+ export default data;
468
+
469
+ // test.ts
470
+ import data from './main';
471
+
472
+ data.foo.push('bar');
473
+ //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
474
+ ```
475
+
476
+ @category Utilities
477
+ */
478
+ /* eslint-disable @typescript-eslint/no-restricted-types */
479
+ export type ReadonlyDeep<T> = T extends Primitive | ((...args: any[]) => unknown)
480
+ ? T
481
+ : T extends ReadonlyMap<infer KeyType, infer ValueType>
482
+ ? ReadonlyMapDeep<KeyType, ValueType>
483
+ : T extends ReadonlySet<infer ItemType>
484
+ ? ReadonlySetDeep<ItemType>
485
+ : T extends object
486
+ ? ReadonlyObjectDeep<T>
487
+ : unknown
488
+
489
+ /**
490
+ Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
491
+ */
492
+ interface ReadonlyMapDeep<KeyType, ValueType>
493
+ extends ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>> {}
494
+
495
+ /**
496
+ Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
497
+ */
498
+ interface ReadonlySetDeep<ItemType> extends ReadonlySet<ReadonlyDeep<ItemType>> {}
499
+
500
+ /**
501
+ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
502
+ */
503
+ type ReadonlyObjectDeep<ObjectType extends object> = {
504
+ readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
505
+ }
506
+
507
+ /* eslint-enable */