@augment-vir/core 31.71.2 → 31.71.4
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Digit } from '../number/digit.js';
|
|
1
2
|
/**
|
|
2
3
|
* Creates a tuple with length of `OriginalTuple` with values of `NewValueType`.
|
|
3
4
|
*
|
|
@@ -49,14 +50,31 @@ export type RemoveFirstTupleEntry<T extends any[]> = T extends [
|
|
|
49
50
|
any?,
|
|
50
51
|
...infer Tail
|
|
51
52
|
] ? Tail : any[];
|
|
53
|
+
/**
|
|
54
|
+
* Detects whether `Length` is a safe size to materialize as a tuple at the type level. Only matches
|
|
55
|
+
* non-negative integer literals 0–99, whose stringification is exactly one or two ASCII digits.
|
|
56
|
+
* Anything else — sizes ≥ 100, negatives, non-integers, scientific notation, or a non-literal
|
|
57
|
+
* `number` — fails to match, because `_TupleOf` either exceeds TS's recursion limit or never
|
|
58
|
+
* terminates for those inputs.
|
|
59
|
+
*
|
|
60
|
+
* @category Array
|
|
61
|
+
* @category Package : @augment-vir/common
|
|
62
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
63
|
+
*/
|
|
64
|
+
export type IsTupleSizeSafe<Length extends number> = `${Length}` extends `${Digit}` | `${Digit}${Digit}` ? true : false;
|
|
52
65
|
/**
|
|
53
66
|
* A tuple with entries of type `Element` and length of `Length`.
|
|
54
67
|
*
|
|
68
|
+
* Only literal `Length` values from 0 to 99 produce a precise tuple; anything else (≥ 100,
|
|
69
|
+
* negatives, non-integers, scientific notation, or a non-literal `number`) falls back to
|
|
70
|
+
* `Element[]`, because the recursive helper either exceeds TS's recursion limit or never terminates
|
|
71
|
+
* for those inputs.
|
|
72
|
+
*
|
|
55
73
|
* @category Array
|
|
56
74
|
* @category Package : @augment-vir/common
|
|
57
75
|
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
58
76
|
*/
|
|
59
|
-
export type Tuple<Element, Length extends number> = Length extends Length ?
|
|
77
|
+
export type Tuple<Element, Length extends number> = Length extends Length ? IsTupleSizeSafe<Length> extends true ? _TupleOf<Element, Length, []> : Element[] : never;
|
|
60
78
|
type _TupleOf<ArrayElementGeneric, LengthGeneric extends number, FullArrayGeneric extends unknown[]> = FullArrayGeneric['length'] extends LengthGeneric ? FullArrayGeneric : _TupleOf<ArrayElementGeneric, LengthGeneric, [
|
|
61
79
|
ArrayElementGeneric,
|
|
62
80
|
...FullArrayGeneric
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A union of all single digits in base 10.
|
|
3
|
+
*
|
|
4
|
+
* @category Number
|
|
5
|
+
* @category Package : @augment-vir/common
|
|
6
|
+
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
|
|
7
|
+
*/
|
|
8
|
+
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './augments/http/http-status.js';
|
|
|
13
13
|
export * from './augments/json/json-compatible.js';
|
|
14
14
|
export * from './augments/min-max.js';
|
|
15
15
|
export * from './augments/narrow-type.js';
|
|
16
|
+
export * from './augments/number/digit.js';
|
|
16
17
|
export * from './augments/object/generic-object-type.js';
|
|
17
18
|
export * from './augments/object/object-keys.js';
|
|
18
19
|
export * from './augments/object/object-sort.js';
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from './augments/http/http-status.js';
|
|
|
13
13
|
export * from './augments/json/json-compatible.js';
|
|
14
14
|
export * from './augments/min-max.js';
|
|
15
15
|
export * from './augments/narrow-type.js';
|
|
16
|
+
export * from './augments/number/digit.js';
|
|
16
17
|
export * from './augments/object/generic-object-type.js';
|
|
17
18
|
export * from './augments/object/object-keys.js';
|
|
18
19
|
export * from './augments/object/object-sort.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/core",
|
|
3
|
-
"version": "31.71.
|
|
3
|
+
"version": "31.71.4",
|
|
4
4
|
"description": "Core augment-vir augments. Use @augment-vir/common instead.",
|
|
5
5
|
"homepage": "https://github.com/electrovir/augment-vir",
|
|
6
6
|
"bugs": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/electrovir/augment-vir.git"
|
|
12
12
|
},
|
|
13
|
-
"license": "(MIT
|
|
13
|
+
"license": "(MIT OR CC0-1.0)",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "electrovir",
|
|
16
16
|
"url": "https://github.com/electrovir"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"type-fest": "^5.6.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^25.
|
|
38
|
+
"@types/node": "^25.9.1",
|
|
39
39
|
"c8": "^11.0.0",
|
|
40
40
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
41
41
|
"typescript": "^5.9.3"
|