ts-data-forge 9.0.1 → 11.0.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/README.md +1 -1
- package/dist/array/impl/array-utils-creation.d.mts +4 -4
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +4 -4
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts +117 -0
- package/dist/array/impl/array-utils-length-bounded-array-cast.d.mts.map +1 -0
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +37 -0
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -0
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts +159 -0
- package/dist/array/impl/array-utils-length-bounded-array-guard.d.mts.map +1 -0
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +7 -0
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -0
- package/dist/array/impl/array-utils-modification.d.mts +11 -11
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +9 -9
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +3 -3
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +9 -9
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +16 -10
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +17 -17
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +5 -5
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/array/impl/index.d.mts +2 -0
- package/dist/array/impl/index.d.mts.map +1 -1
- package/dist/array/impl/index.mjs +3 -1
- package/dist/array/impl/index.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -1
- package/dist/guard/index.d.mts +0 -1
- package/dist/guard/index.d.mts.map +1 -1
- package/dist/guard/index.mjs +0 -1
- package/dist/guard/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/string/index.d.mts +2 -0
- package/dist/string/index.d.mts.map +1 -0
- package/dist/string/index.mjs +2 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/str.d.mts +273 -0
- package/dist/string/str.d.mts.map +1 -0
- package/dist/string/str.mjs +42 -0
- package/dist/string/str.mjs.map +1 -0
- package/package.json +30 -92
- package/src/array/impl/array-utils-creation.mts +5 -4
- package/src/array/impl/array-utils-element-access.mts +3 -3
- package/src/array/impl/array-utils-element-access.test.mts +3 -3
- package/src/array/impl/array-utils-length-bounded-array-cast.mts +190 -0
- package/src/array/impl/array-utils-length-bounded-array-cast.test.mts +118 -0
- package/src/array/impl/array-utils-length-bounded-array-guard.mts +195 -0
- package/src/array/impl/array-utils-length-bounded-array-guard.test.mts +169 -0
- package/src/array/impl/array-utils-modification.mts +16 -15
- package/src/array/impl/array-utils-modification.test.mts +10 -5
- package/src/array/impl/array-utils-reducing-value.mts +9 -9
- package/src/array/impl/array-utils-size.mts +2 -2
- package/src/array/impl/array-utils-slicing.mts +24 -13
- package/src/array/impl/array-utils-transformation.mts +22 -16
- package/src/array/impl/array-utils-transformation.test.mts +19 -19
- package/src/array/impl/array-utils-validation.mts +24 -24
- package/src/array/impl/array-utils-validation.test.mts +94 -92
- package/src/array/impl/index.mts +2 -0
- package/src/collections/queue.test.mts +1 -1
- package/src/guard/index.mts +0 -1
- package/src/index.mts +1 -0
- package/src/object/object.test.mts +3 -3
- package/src/string/index.mts +1 -0
- package/src/string/str.mts +371 -0
- package/src/string/str.test.mts +215 -0
- package/dist/guard/is-length-bounded-string.d.mts +0 -164
- package/dist/guard/is-length-bounded-string.d.mts.map +0 -1
- package/dist/guard/is-length-bounded-string.mjs +0 -7
- package/dist/guard/is-length-bounded-string.mjs.map +0 -1
- package/src/guard/is-length-bounded-string.mts +0 -199
- package/src/guard/is-length-bounded-string.test.mts +0 -170
package/README.md
CHANGED
|
@@ -384,7 +384,7 @@ const sum = Arr.sum(numbers);
|
|
|
384
384
|
assert.isTrue(sum === 20);
|
|
385
385
|
|
|
386
386
|
// Type-safe length checking
|
|
387
|
-
if (Arr.
|
|
387
|
+
if (Arr.isMinLengthTuple(numbers, 2)) {
|
|
388
388
|
// numbers is now guaranteed to have at least 2 elements
|
|
389
389
|
expectType<typeof numbers, readonly [number, number, ...number[]]>('=');
|
|
390
390
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BoolOr, type FixedLengthTuple, type Index, type IsUnion, type List, type Min, type NonEmptyArray, type NonZeroSafeIntWithSmallInt, type PositiveSafeIntWithSmallInt, type RelaxedExclude, type SafeInt, type SafeIntWithSmallInt, type SafeUint, type SafeUintWithSmallInt, type Seq, type SmallUint, type StructuralPrefixLength } from 'ts-type-forge';
|
|
2
2
|
import { type SizeType } from '../../types.mjs';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an array of zeros with the specified length.
|
|
@@ -15,7 +15,7 @@ import { type SizeType } from '../../types.mjs';
|
|
|
15
15
|
* assert.deepStrictEqual(threeZeros, [0, 0, 0]);
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export declare const zeros: <N extends SizeType.ArgArr>(len: N) => N extends SmallUint ?
|
|
18
|
+
export declare const zeros: <N extends SizeType.ArgArr>(len: N) => N extends SmallUint ? FixedLengthTuple<N, 0> : N extends SizeType.ArgArrPositive ? NonEmptyArray<0> : readonly 0[];
|
|
19
19
|
/**
|
|
20
20
|
* Creates a sequence of consecutive integers from 0 to `len-1`.
|
|
21
21
|
*
|
|
@@ -47,13 +47,13 @@ export declare const seq: <N extends SizeType.ArgArr>(len: N) => N extends Small
|
|
|
47
47
|
* assert.deepStrictEqual(emptyStrings, []);
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
export declare const create: <N extends SizeType.ArgArr, const V>(len: N, init: V) => N extends
|
|
50
|
+
export declare const create: <N extends SizeType.ArgArr, const V>(len: N, init: V) => N extends StructuralPrefixLength ? FixedLengthTuple<N, V> : N extends SizeType.ArgArrPositive ? NonEmptyArray<V> : readonly V[];
|
|
51
51
|
/**
|
|
52
52
|
* Alias for `create`.
|
|
53
53
|
*
|
|
54
54
|
* @see {@link create}
|
|
55
55
|
*/
|
|
56
|
-
export declare const newArray: <N extends SizeType.ArgArr, const V>(len: N, init: V) => N extends
|
|
56
|
+
export declare const newArray: <N extends SizeType.ArgArr, const V>(len: N, init: V) => N extends StructuralPrefixLength ? FixedLengthTuple<N, V> : N extends SizeType.ArgArrPositive ? NonEmptyArray<V> : readonly V[];
|
|
57
57
|
/**
|
|
58
58
|
* Generates an array from a generator function.
|
|
59
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-creation.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-creation.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"array-utils-creation.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-creation.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK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B,KAAK,CACnB,KAAK,EAAE,oBAAoB,EAC3B,GAAG,EAAE,oBAAoB,EACzB,IAAI,CAAC,EAAE,2BAA2B,GACjC,SAAS,QAAQ,EAAE,CAAC;AAEvB,wBAAgB,KAAK,CACnB,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,mBAAmB,EACxB,IAAI,CAAC,EAAE,0BAA0B,GAChC,SAAS,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-creation.mjs","sources":["../../../src/array/impl/array-utils-creation.mts"],"sourcesContent":["import {\n type
|
|
1
|
+
{"version":3,"file":"array-utils-creation.mjs","sources":["../../../src/array/impl/array-utils-creation.mts"],"sourcesContent":["import {\n type BoolOr,\n type FixedLengthTuple,\n type Index,\n type IsUnion,\n type List,\n type Min,\n type NonEmptyArray,\n type NonZeroSafeIntWithSmallInt,\n type PositiveSafeIntWithSmallInt,\n type RelaxedExclude,\n type SafeInt,\n type SafeIntWithSmallInt,\n type SafeUint,\n type SafeUintWithSmallInt,\n type Seq,\n type SmallUint,\n type StructuralPrefixLength,\n} from 'ts-type-forge';\nimport { expectType } from '../../expect-type.mjs';\nimport { range as rangeIterator } from '../../iterator/index.mjs';\nimport { type SizeType } from '../../types.mjs';\n\n/**\n * Creates an array of zeros with the specified length.\n *\n * @example\n *\n * ```ts\n * const emptyZeros = Arr.zeros(0);\n *\n * const threeZeros = Arr.zeros(3);\n *\n * assert.deepStrictEqual(emptyZeros, []);\n *\n * assert.deepStrictEqual(threeZeros, [0, 0, 0]);\n * ```\n */\nexport const zeros = <N extends SizeType.ArgArr>(\n len: N,\n): N extends SmallUint\n ? FixedLengthTuple<N, 0>\n : N extends SizeType.ArgArrPositive\n ? NonEmptyArray<0>\n : readonly 0[] =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Array.from({ length: len }, () => 0) as never;\n\n/**\n * Creates a sequence of consecutive integers from 0 to `len-1`.\n *\n * @example\n *\n * ```ts\n * const emptySeq = Arr.seq(0);\n *\n * const firstFive = Arr.seq(5);\n *\n * assert.deepStrictEqual(emptySeq, []);\n *\n * assert.deepStrictEqual(firstFive, [0, 1, 2, 3, 4]);\n * ```\n */\nexport const seq = <N extends SizeType.ArgArr>(\n len: N,\n): N extends SmallUint\n ? Seq<N>\n : N extends SizeType.ArgArrPositive\n ? NonEmptyArray<SizeType.Arr>\n : readonly SizeType.Arr[] =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Array.from({ length: len }, (_, i) => i) as never;\n\n/**\n * Creates a new array of the specified length, filled with the initial value.\n *\n * @example\n *\n * ```ts\n * const threeOnes = Arr.create(3, 1);\n *\n * const emptyStrings = Arr.create(0, 'Ada');\n *\n * assert.deepStrictEqual(threeOnes, [1, 1, 1]);\n *\n * assert.deepStrictEqual(emptyStrings, []);\n * ```\n */\nexport const create = <N extends SizeType.ArgArr, const V>(\n len: N,\n init: V,\n): N extends StructuralPrefixLength\n ? FixedLengthTuple<N, V>\n : N extends SizeType.ArgArrPositive\n ? NonEmptyArray<V>\n : readonly V[] =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Array.from({ length: Math.max(0, len) }, () => init) as never;\n\n/**\n * Alias for `create`.\n *\n * @see {@link create}\n */\nexport const newArray = create;\n\n/**\n * Generates an array from a generator function.\n *\n * @example\n *\n * ```ts\n * const numbers = Arr.generate(function* () {\n * yield 1;\n *\n * yield 2;\n *\n * yield 3;\n * });\n *\n * assert.deepStrictEqual(numbers, [1, 2, 3]);\n * ```\n */\nexport const generate = <T,>(\n generatorFn: () => Generator<T, void, unknown>,\n): readonly T[] => Array.from(generatorFn());\n\n/**\n * Generates an array from an async generator function.\n *\n * @example\n *\n * ```ts\n * const values = await Arr.generateAsync(async function* () {\n * yield 'Ada';\n *\n * await Promise.resolve();\n *\n * yield 'Lovelace';\n * });\n *\n * assert.deepStrictEqual(values, ['Ada', 'Lovelace']);\n * ```\n */\nexport const generateAsync = <T,>(\n generatorFn: () => AsyncGenerator<T, void, unknown>,\n): Promise<readonly T[]> => Array.fromAsync(generatorFn());\n\n/**\n * Creates a shallow copy of an array.\n *\n * @example\n *\n * ```ts\n * const original = [{ id: 1 }, { id: 2 }] as const;\n *\n * const cloned = Arr.copy(original);\n *\n * assert.deepStrictEqual(cloned, original);\n *\n * assert.notStrictEqual(cloned, original);\n * ```\n */\nexport const copy = <const Ar extends readonly unknown[]>(array: Ar): Ar =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n array.slice() as unknown as Ar;\n\ntype LT = Readonly<{ [N in SmallUint]: Index<N> }>;\n\ntype RangeList<S extends SmallUint, E extends SmallUint> =\n BoolOr<IsUnion<S>, IsUnion<E>> extends true\n ? readonly RelaxedExclude<LT[E], LT[Min<S>]>[] // Avoid incorrect type calculation for unions with Seq\n : List.Skip<S, Seq<E>>;\n\nexpectType<RangeList<1, 5>, readonly [1, 2, 3, 4]>('=');\n\nexpectType<RangeList<1, 2>, readonly [1]>('=');\n\nexpectType<RangeList<1, 1>, readonly []>('=');\n\nexpectType<RangeList<1, 1 | 3>, readonly (1 | 2)[]>('=');\n\nexpectType<RangeList<1 | 3, 3 | 5>, readonly (1 | 2 | 3 | 4)[]>('=');\n\nexpectType<RangeList<1 | 2 | 3, 5 | 6 | 7>, readonly (1 | 2 | 3 | 4 | 5 | 6)[]>(\n '=',\n);\n\nexpectType<RangeList<5, 1>, readonly []>('=');\n\n/**\n * Creates an array of numbers within a specified range with optional step.\n *\n * @example\n *\n * ```ts\n * const ascending = Arr.range(asUint32(1), asUint32(5));\n *\n * const empty = Arr.range(asUint32(2), asUint32(2));\n *\n * assert.deepStrictEqual(ascending, [1, 2, 3, 4]);\n *\n * assert.deepStrictEqual(empty, []);\n * ```\n */\nexport function range<S extends SmallUint, E extends SmallUint>(\n start: S,\n end: E,\n step?: 1,\n): RangeList<S, E>;\n\nexport function range(\n start: SafeUintWithSmallInt,\n end: SafeUintWithSmallInt,\n step?: PositiveSafeIntWithSmallInt,\n): readonly SafeUint[];\n\nexport function range(\n start: SafeIntWithSmallInt,\n end: SafeIntWithSmallInt,\n step?: NonZeroSafeIntWithSmallInt,\n): readonly SafeInt[];\n\nexport function range(\n start: SafeIntWithSmallInt,\n end: SafeIntWithSmallInt,\n step: NonZeroSafeIntWithSmallInt = 1,\n): readonly SafeInt[] {\n return Array.from(rangeIterator(start, end, step));\n}\n"],"names":["rangeIterator"],"mappings":";;AAsCO,MAAM,QAAQ,CACnB,GAAA;AAAA;AAAA,EAOA,MAAM,IAAA,CAAK,EAAE,QAAQ,GAAA,EAAI,EAAG,MAAM,CAAC;AAAA;AAiB9B,MAAM,MAAM,CACjB,GAAA;AAAA;AAAA,EAOA,KAAA,CAAM,KAAK,EAAE,MAAA,EAAQ,KAAI,EAAG,CAAC,CAAA,EAAG,CAAA,KAAM,CAAC;AAAA;MAiB5B,MAAA,GAAS,CACpB,GAAA,EACA,IAAA;AAAA;AAAA,EAOA,KAAA,CAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,GAAG,CAAA,EAAE,EAAG,MAAM,IAAI;AAAA;AAO9C,MAAM,QAAA,GAAW;AAmBjB,MAAM,WAAW,CACtB,WAAA,KACiB,KAAA,CAAM,IAAA,CAAK,aAAa;AAmBpC,MAAM,gBAAgB,CAC3B,WAAA,KAC0B,KAAA,CAAM,SAAA,CAAU,aAAa;AAiBlD,MAAM,OAAO,CAAsC,KAAA;AAAA;AAAA,EAExD,MAAM,KAAA;AAAM;AA0DP,SAAS,KAAA,CACd,KAAA,EACA,GAAA,EACA,IAAA,GAAmC,CAAA,EACf;AACpB,EAAA,OAAO,MAAM,IAAA,CAAKA,OAAA,CAAc,KAAA,EAAO,GAAA,EAAK,IAAI,CAAC,CAAA;AACnD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type NonEmptyTuple } from 'ts-type-forge';
|
|
2
2
|
import { Optional } from '../../functional/index.mjs';
|
|
3
3
|
import { type ArgArrayIndexWithNegative, type None, type SizeType, type Some } from '../../types.mjs';
|
|
4
4
|
/**
|
|
@@ -43,7 +43,7 @@ export declare function at(index: SizeType.ArgArrWithNegative): <E>(array: reado
|
|
|
43
43
|
* assert.deepStrictEqual(none, Optional.none);
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
export declare const head: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [infer E, ...unknown[]] ? Some<E> : Ar extends
|
|
46
|
+
export declare const head: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [infer E, ...unknown[]] ? Some<E> : Ar extends NonEmptyTuple<infer E> ? Some<E> : Optional<Ar[number]>;
|
|
47
47
|
/**
|
|
48
48
|
* Returns the last element of an array as an Optional.
|
|
49
49
|
*
|
|
@@ -63,11 +63,11 @@ export declare const head: <const Ar extends readonly unknown[]>(array: Ar) => A
|
|
|
63
63
|
* assert.deepStrictEqual(none, Optional.none);
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
export declare const last: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [...unknown[], infer E] ? Some<E> : Ar extends
|
|
66
|
+
export declare const last: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [...unknown[], infer E] ? Some<E> : Ar extends NonEmptyTuple<infer E> ? Some<E> : Optional<Ar[number]>;
|
|
67
67
|
/**
|
|
68
68
|
* Alias for `head`.
|
|
69
69
|
*
|
|
70
70
|
* @see {@link head}
|
|
71
71
|
*/
|
|
72
|
-
export declare const first: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [infer E, ...unknown[]] ? Some<E> : Ar extends
|
|
72
|
+
export declare const first: <const Ar extends readonly unknown[]>(array: Ar) => Ar extends readonly [] ? None : Ar extends readonly [infer E, ...unknown[]] ? Some<E> : Ar extends NonEmptyTuple<infer E> ? Some<E> : Optional<Ar[number]>;
|
|
73
73
|
//# sourceMappingURL=array-utils-element-access.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-element-access.mjs","sources":["../../../src/array/impl/array-utils-element-access.mts"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"file":"array-utils-element-access.mjs","sources":["../../../src/array/impl/array-utils-element-access.mts"],"sourcesContent":["import { type NonEmptyTuple } from 'ts-type-forge';\nimport { Optional, pipe } from '../../functional/index.mjs';\nimport {\n type ArgArrayIndexWithNegative,\n type None,\n type SizeType,\n type Some,\n} from '../../types.mjs';\n\n/**\n * Safely retrieves an element at a given index from an array, returning an Optional.\n *\n * @example\n *\n * ```ts\n * const letters: readonly string[] = ['a', 'b', 'c'] as const;\n *\n * const two = Arr.at(letters, 1);\n *\n * const last = Arr.at(-1)(letters);\n *\n * const missing = Arr.at(letters, 5);\n *\n * assert.deepStrictEqual(two, Optional.some('b'));\n *\n * assert.deepStrictEqual(last, Optional.some('c'));\n *\n * assert.deepStrictEqual(missing, Optional.none);\n * ```\n */\nexport function at<const Ar extends readonly unknown[]>(\n array: Ar,\n index: ArgArrayIndexWithNegative<Ar>,\n): Optional<Ar[number]>;\n\n// Curried version\n\nexport function at(\n index: SizeType.ArgArrWithNegative,\n): <E>(array: readonly E[]) => Optional<E>;\n\nexport function at<E>(\n ...args:\n | readonly [array: readonly E[], index: SizeType.ArgArrWithNegative]\n | readonly [index: SizeType.ArgArrWithNegative]\n): Optional<E> | ((array: readonly E[]) => Optional<E>) {\n switch (args.length) {\n case 2: {\n const [array, index] = args;\n\n return pipe(index < 0 ? array.length + index : index).map(\n (normalizedIndex) =>\n normalizedIndex < 0 || normalizedIndex >= array.length\n ? Optional.none\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n Optional.some(array[normalizedIndex]!),\n ).value;\n }\n\n case 1: {\n const [index] = args;\n\n return (array) => at(array, index);\n }\n }\n}\n\n/**\n * Returns the first element of an array as an Optional.\n *\n * @example\n *\n * ```ts\n * const users = [{ id: 1 }, { id: 2 }] as const;\n *\n * const empty: readonly Readonly<{ id: number }>[] = [] as const;\n *\n * const first = Arr.head(users);\n *\n * const none = Arr.head(empty);\n *\n * assert.deepStrictEqual(first, Optional.some({ id: 1 }));\n *\n * assert.deepStrictEqual(none, Optional.none);\n * ```\n */\nexport const head = <const Ar extends readonly unknown[]>(\n array: Ar,\n): Ar extends readonly []\n ? None\n : Ar extends readonly [infer E, ...unknown[]]\n ? Some<E>\n : Ar extends NonEmptyTuple<infer E>\n ? Some<E>\n : Optional<Ar[number]> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (array.length === 0 ? Optional.none : Optional.some(array.at(0))) as never;\n\n/**\n * Returns the last element of an array as an Optional.\n *\n * @example\n *\n * ```ts\n * const queue = ['first', 'second'] as const;\n *\n * const emptyQueue: readonly string[] = [] as const;\n *\n * const lastValue = Arr.last(queue);\n *\n * const none = Arr.last(emptyQueue);\n *\n * assert.deepStrictEqual(lastValue, Optional.some('second'));\n *\n * assert.deepStrictEqual(none, Optional.none);\n * ```\n */\nexport const last = <const Ar extends readonly unknown[]>(\n array: Ar,\n): Ar extends readonly []\n ? None\n : Ar extends readonly [...unknown[], infer E]\n ? Some<E>\n : Ar extends NonEmptyTuple<infer E>\n ? Some<E>\n : Optional<Ar[number]> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n (array.length === 0 ? Optional.none : Optional.some(array.at(-1))) as never;\n\n/**\n * Alias for `head`.\n *\n * @see {@link head}\n */\nexport const first = head;\n"],"names":["index","Optional.none","Optional.some"],"mappings":";;;;;AAyCO,SAAS,MACX,IAAA,EAGmD;AACtD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAA,EAAOA,OAAK,CAAA,GAAI,IAAA;AAEvB,MAAA,OAAO,KAAKA,OAAA,GAAQ,CAAA,GAAI,MAAM,MAAA,GAASA,OAAA,GAAQA,OAAK,CAAA,CAAE,GAAA;AAAA,QACpD,CAAC,eAAA,KACC,eAAA,GAAkB,KAAK,eAAA,IAAmB,KAAA,CAAM,SAC5CC,IAAS;AAAA;AAAA,UAETC,IAAS,CAAK,KAAA,CAAM,eAAe,CAAE;AAAA;AAAA,OAC7C,CAAE,KAAA;AAAA,IACJ;AAAA,IAEA,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,CAAC,KAAK,CAAA,GAAI,IAAA;AAEhB,MAAA,OAAO,CAAC,KAAA,KAAU,EAAA,CAAG,KAAA,EAAO,KAAK,CAAA;AAAA,IACnC;AAAA;AAEJ;AAqBO,MAAM,OAAO,CAClB,KAAA;AAAA;AAAA,EASC,KAAA,CAAM,MAAA,KAAW,CAAA,GAAID,IAAS,GAAOC,IAAS,CAAK,KAAA,CAAM,EAAA,CAAG,CAAC,CAAC;AAAA;AAqB1D,MAAM,OAAO,CAClB,KAAA;AAAA;AAAA,EASC,KAAA,CAAM,MAAA,KAAW,CAAA,GAAID,IAAS,GAAOC,IAAS,CAAK,KAAA,CAAM,EAAA,CAAG,EAAE,CAAC;AAAA;AAO3D,MAAM,KAAA,GAAQ;;;;"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
|
|
2
|
+
/**
|
|
3
|
+
* Casts an array to `FixedLengthArray<Length, E>` after checking that it has
|
|
4
|
+
* exactly `length` elements.
|
|
5
|
+
*
|
|
6
|
+
* Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the
|
|
7
|
+
* length is verified at runtime, and the original array type (e.g. tuple
|
|
8
|
+
* types) is preserved via intersection, so the result also benefits from the
|
|
9
|
+
* structural tuple prefix (in-range indexed access without `undefined` under
|
|
10
|
+
* `noUncheckedIndexedAccess`).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const rgb = Arr.asFixedLengthArray([255, 128, 0], 3);
|
|
16
|
+
*
|
|
17
|
+
* const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
|
|
18
|
+
* const red: number = rgb[0]; // OK — no `undefined`
|
|
19
|
+
*
|
|
20
|
+
* // Arr.asFixedLengthArray([255, 128], 3); // throws TypeError
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
24
|
+
* @template Length - The exact number of elements.
|
|
25
|
+
* @param xs - The array to cast.
|
|
26
|
+
* @param length - The exact number of elements.
|
|
27
|
+
* @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.
|
|
28
|
+
* @throws {TypeError} If `xs.length !== length`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const asFixedLengthArray: <Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length) => FixedLengthArray<Length, Xs[number]> & Xs;
|
|
31
|
+
/**
|
|
32
|
+
* Casts an array to `MinLengthArray<MinLength, E>` after checking that it has
|
|
33
|
+
* at least `minLength` elements.
|
|
34
|
+
*
|
|
35
|
+
* Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the
|
|
36
|
+
* length is verified at runtime, and the original array type (e.g. tuple
|
|
37
|
+
* types) is preserved via intersection, so the result also benefits from the
|
|
38
|
+
* structural tuple prefix (indexed access below `min(N, 10)` without
|
|
39
|
+
* `undefined` under `noUncheckedIndexedAccess`).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* const history = Arr.asMinLengthArray([0, 1, 2, 3], 3);
|
|
45
|
+
*
|
|
46
|
+
* const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)
|
|
47
|
+
* const first: number = history[0]; // OK — no `undefined`
|
|
48
|
+
*
|
|
49
|
+
* // Arr.asMinLengthArray([0], 3); // throws TypeError
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
53
|
+
* @template MinLength - The minimum number of elements (inclusive).
|
|
54
|
+
* @param xs - The array to cast.
|
|
55
|
+
* @param minLength - The minimum number of elements (inclusive).
|
|
56
|
+
* @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.
|
|
57
|
+
* @throws {TypeError} If `xs.length < minLength`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const asMinLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength) => MinLengthArray<MinLength, Xs[number]> & Xs;
|
|
60
|
+
/**
|
|
61
|
+
* Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has
|
|
62
|
+
* at most `maxLength` elements.
|
|
63
|
+
*
|
|
64
|
+
* Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the
|
|
65
|
+
* length is verified at runtime, and the original array type (e.g. tuple
|
|
66
|
+
* types) is preserved via intersection.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const tags = Arr.asMaxLengthArray(['a', 'b', 'c'], 8);
|
|
72
|
+
*
|
|
73
|
+
* const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)
|
|
74
|
+
*
|
|
75
|
+
* // Arr.asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
79
|
+
* @template MaxLength - The maximum number of elements (inclusive).
|
|
80
|
+
* @param xs - The array to cast.
|
|
81
|
+
* @param maxLength - The maximum number of elements (inclusive).
|
|
82
|
+
* @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.
|
|
83
|
+
* @throws {TypeError} If `xs.length > maxLength`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const asMaxLengthArray: <Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength) => MaxLengthArray<MaxLength, Xs[number]> & Xs;
|
|
86
|
+
/**
|
|
87
|
+
* Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after
|
|
88
|
+
* checking that its length is within the inclusive range
|
|
89
|
+
* `[minLength, maxLength]`.
|
|
90
|
+
*
|
|
91
|
+
* Use this instead of writing
|
|
92
|
+
* `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified
|
|
93
|
+
* at runtime, and the original array type (e.g. tuple types) is preserved via
|
|
94
|
+
* intersection.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* const selection = Arr.asBoundedLengthArray([1, 2, 3], 1, 5);
|
|
100
|
+
*
|
|
101
|
+
* const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK
|
|
102
|
+
*
|
|
103
|
+
* // Arr.asBoundedLengthArray([], 1, 5); // throws TypeError
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
107
|
+
* @template MinLength - The minimum number of elements (inclusive).
|
|
108
|
+
* @template MaxLength - The maximum number of elements (inclusive).
|
|
109
|
+
* @param xs - The array to cast.
|
|
110
|
+
* @param minLength - The minimum number of elements (inclusive).
|
|
111
|
+
* @param maxLength - The maximum number of elements (inclusive).
|
|
112
|
+
* @returns `xs` typed as
|
|
113
|
+
* `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.
|
|
114
|
+
* @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.
|
|
115
|
+
*/
|
|
116
|
+
export declare const asBoundedLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength) => BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
|
|
117
|
+
//# sourceMappingURL=array-utils-length-bounded-array-cast.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-cast.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,kBAAkB,GAC7B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,MAE1B,EAAE,UACE,MAAM,KACb,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQ1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,oBAAoB,GAC/B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,aACT,SAAS,KACnB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAQzD,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray } from './array-utils-length-bounded-array-guard.mjs';
|
|
2
|
+
|
|
3
|
+
const asFixedLengthArray = (xs, length) => {
|
|
4
|
+
if (!isFixedLengthArray(xs, length)) {
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
`Expected an array of length ${length}, got an array of length ${xs.length}`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return xs;
|
|
10
|
+
};
|
|
11
|
+
const asMinLengthArray = (xs, minLength) => {
|
|
12
|
+
if (!isMinLengthArray(xs, minLength)) {
|
|
13
|
+
throw new TypeError(
|
|
14
|
+
`Expected an array of length >= ${minLength}, got an array of length ${xs.length}`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return xs;
|
|
18
|
+
};
|
|
19
|
+
const asMaxLengthArray = (xs, maxLength) => {
|
|
20
|
+
if (!isMaxLengthArray(xs, maxLength)) {
|
|
21
|
+
throw new TypeError(
|
|
22
|
+
`Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return xs;
|
|
26
|
+
};
|
|
27
|
+
const asBoundedLengthArray = (xs, minLength, maxLength) => {
|
|
28
|
+
if (!isBoundedLengthArray(xs, minLength, maxLength)) {
|
|
29
|
+
throw new TypeError(
|
|
30
|
+
`Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return xs;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { asBoundedLengthArray, asFixedLengthArray, asMaxLengthArray, asMinLengthArray };
|
|
37
|
+
//# sourceMappingURL=array-utils-length-bounded-array-cast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-cast.mjs","sources":["../../../src/array/impl/array-utils-length-bounded-array-cast.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\nimport {\n isBoundedLengthArray,\n isFixedLengthArray,\n isMaxLengthArray,\n isMinLengthArray,\n} from './array-utils-length-bounded-array-guard.mjs';\n\n/**\n * Casts an array to `FixedLengthArray<Length, E>` after checking that it has\n * exactly `length` elements.\n *\n * Use this instead of writing `xs as unknown as FixedLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (in-range indexed access without `undefined` under\n * `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const rgb = Arr.asFixedLengthArray([255, 128, 0], 3);\n *\n * const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)\n * const red: number = rgb[0]; // OK — no `undefined`\n *\n * // Arr.asFixedLengthArray([255, 128], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to cast.\n * @param length - The exact number of elements.\n * @returns `xs` typed as `FixedLengthArray<Length, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length !== length`.\n */\nexport const asFixedLengthArray = <\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(\n xs: Xs,\n length: Length,\n): FixedLengthArray<Length, Xs[number]> & Xs => {\n if (!isFixedLengthArray(xs, length)) {\n throw new TypeError(\n `Expected an array of length ${length}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MinLengthArray<MinLength, E>` after checking that it has\n * at least `minLength` elements.\n *\n * Use this instead of writing `xs as unknown as MinLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection, so the result also benefits from the\n * structural tuple prefix (indexed access below `min(N, 10)` without\n * `undefined` under `noUncheckedIndexedAccess`).\n *\n * @example\n *\n * ```ts\n * const history = Arr.asMinLengthArray([0, 1, 2, 3], 3);\n *\n * const nonEmpty: MinLengthArray<1, number> = history; // OK (3 >= 1)\n * const first: number = history[0]; // OK — no `undefined`\n *\n * // Arr.asMinLengthArray([0], 3); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `xs` typed as `MinLengthArray<MinLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength`.\n */\nexport const asMinLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n): MinLengthArray<MinLength, Xs[number]> & Xs => {\n if (!isMinLengthArray(xs, minLength)) {\n throw new TypeError(\n `Expected an array of length >= ${minLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `MaxLengthArray<MaxLength, E>` after checking that it has\n * at most `maxLength` elements.\n *\n * Use this instead of writing `xs as unknown as MaxLengthArray<N, E>`: the\n * length is verified at runtime, and the original array type (e.g. tuple\n * types) is preserved via intersection.\n *\n * @example\n *\n * ```ts\n * const tags = Arr.asMaxLengthArray(['a', 'b', 'c'], 8);\n *\n * const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)\n *\n * // Arr.asMaxLengthArray(['a', 'b', 'c'], 2); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length > maxLength`.\n */\nexport const asMaxLengthArray = <\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n maxLength: MaxLength,\n): MaxLengthArray<MaxLength, Xs[number]> & Xs => {\n if (!isMaxLengthArray(xs, maxLength)) {\n throw new TypeError(\n `Expected an array of length <= ${maxLength}, got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n\n/**\n * Casts an array to `BoundedLengthArray<MinLength, MaxLength, E>` after\n * checking that its length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * Use this instead of writing\n * `xs as unknown as BoundedLengthArray<Min, Max, E>`: the length is verified\n * at runtime, and the original array type (e.g. tuple types) is preserved via\n * intersection.\n *\n * @example\n *\n * ```ts\n * const selection = Arr.asBoundedLengthArray([1, 2, 3], 1, 5);\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = selection; // OK\n *\n * // Arr.asBoundedLengthArray([], 1, 5); // throws TypeError\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to cast.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `xs` typed as\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n * @throws {TypeError} If `xs.length < minLength || xs.length > maxLength`.\n */\nexport const asBoundedLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs => {\n if (!isBoundedLengthArray(xs, minLength, maxLength)) {\n throw new TypeError(\n `Expected an array of length in [${minLength}, ${maxLength}], got an array of length ${xs.length}`,\n );\n }\n\n return xs;\n};\n"],"names":[],"mappings":";;AA0CO,MAAM,kBAAA,GAAqB,CAIhC,EAAA,EACA,MAAA,KAC8C;AAC9C,EAAA,IAAI,CAAC,kBAAA,CAAmB,EAAA,EAAI,MAAM,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,4BAAA,EAA+B,MAAM,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAC5E;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AA8BO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KAC+C;AAC/C,EAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,SAAS,CAAA,EAAG;AACpC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,+BAAA,EAAkC,SAAS,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAClF;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AA2BO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KAC+C;AAC/C,EAAA,IAAI,CAAC,gBAAA,CAAiB,EAAA,EAAI,SAAS,CAAA,EAAG;AACpC,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,+BAAA,EAAkC,SAAS,CAAA,yBAAA,EAA4B,EAAA,CAAG,MAAM,CAAA;AAAA,KAClF;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;AAgCO,MAAM,oBAAA,GAAuB,CAKlC,EAAA,EACA,SAAA,EACA,SAAA,KAC8D;AAC9D,EAAA,IAAI,CAAC,oBAAA,CAAqB,EAAA,EAAI,SAAA,EAAW,SAAS,CAAA,EAAG;AACnD,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,mCAAmC,SAAS,CAAA,EAAA,EAAK,SAAS,CAAA,0BAAA,EAA6B,GAAG,MAAM,CAAA;AAAA,KAClG;AAAA,EACF;AAEA,EAAA,OAAO,EAAA;AACT;;;;"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { type BoundedLengthArray, type FixedLengthArray, type MaxLengthArray, type MinLengthArray, type SupportedLength } from 'ts-type-forge';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard that checks if an array has at least `minLength` elements.
|
|
4
|
+
*
|
|
5
|
+
* **Type Narrowing Behavior:**
|
|
6
|
+
*
|
|
7
|
+
* - Narrows the input to `MinLengthArray<MinLength, E>` while preserving the
|
|
8
|
+
* original array type (e.g. tuple types) via intersection.
|
|
9
|
+
* - The length constraint lives only in the brand, so this stays cheap for the
|
|
10
|
+
* type checker even when the element type is large — unlike
|
|
11
|
+
* `isMinLengthTuple`, which narrows to a structural tuple type.
|
|
12
|
+
* - The result participates in the length-constraint subtyping relation: for
|
|
13
|
+
* example, a value narrowed to `MinLengthArray<3, E>` is assignable to
|
|
14
|
+
* `MinLengthArray<1, E>`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const input: readonly number[] = [0, 1, 2, 3];
|
|
20
|
+
*
|
|
21
|
+
* assert.isTrue(Arr.isMinLengthArray(input, 3));
|
|
22
|
+
*
|
|
23
|
+
* assert.isFalse(Arr.isMinLengthArray([0], 3));
|
|
24
|
+
*
|
|
25
|
+
* if (Arr.isMinLengthArray(input, 3)) {
|
|
26
|
+
* const history: MinLengthArray<3, number> = input;
|
|
27
|
+
*
|
|
28
|
+
* const nonEmpty: MinLengthArray<1, number> = input; // OK (3 >= 1)
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
33
|
+
* @template MinLength - The minimum number of elements (inclusive).
|
|
34
|
+
* @param xs - The array to check.
|
|
35
|
+
* @param minLength - The minimum number of elements (inclusive).
|
|
36
|
+
* @returns `true` if `xs.length >= minLength`, `false` otherwise. When `true`,
|
|
37
|
+
* TypeScript narrows `xs` to `MinLengthArray<MinLength, Xs[number]> & Xs`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const isMinLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength>(xs: Xs, minLength: MinLength) => xs is MinLengthArray<MinLength, Xs[number]> & Xs;
|
|
40
|
+
/**
|
|
41
|
+
* Type guard that checks if an array has at most `maxLength` elements.
|
|
42
|
+
*
|
|
43
|
+
* **Type Narrowing Behavior:**
|
|
44
|
+
*
|
|
45
|
+
* - Narrows the input to `MaxLengthArray<MaxLength, E>` while preserving the
|
|
46
|
+
* original array type (e.g. tuple types) via intersection.
|
|
47
|
+
* - The length constraint lives only in the brand, so this stays cheap for the
|
|
48
|
+
* type checker even when the element type is large — unlike
|
|
49
|
+
* `isMaxLengthTuple`, which narrows to a union of tuple types.
|
|
50
|
+
* - The result participates in the length-constraint subtyping relation: for
|
|
51
|
+
* example, a value narrowed to `MaxLengthArray<8, E>` is assignable to
|
|
52
|
+
* `MaxLengthArray<16, E>`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* const input: readonly string[] = ['a', 'b', 'c'];
|
|
58
|
+
*
|
|
59
|
+
* assert.isTrue(Arr.isMaxLengthArray(input, 8));
|
|
60
|
+
*
|
|
61
|
+
* assert.isFalse(Arr.isMaxLengthArray(input, 2));
|
|
62
|
+
*
|
|
63
|
+
* if (Arr.isMaxLengthArray(input, 8)) {
|
|
64
|
+
* const tags: MaxLengthArray<8, string> = input;
|
|
65
|
+
*
|
|
66
|
+
* const relaxed: MaxLengthArray<16, string> = input; // OK (8 <= 16)
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
71
|
+
* @template MaxLength - The maximum number of elements (inclusive).
|
|
72
|
+
* @param xs - The array to check.
|
|
73
|
+
* @param maxLength - The maximum number of elements (inclusive).
|
|
74
|
+
* @returns `true` if `xs.length <= maxLength`, `false` otherwise. When `true`,
|
|
75
|
+
* TypeScript narrows `xs` to `MaxLengthArray<MaxLength, Xs[number]> & Xs`.
|
|
76
|
+
*/
|
|
77
|
+
export declare const isMaxLengthArray: <Xs extends readonly unknown[], MaxLength extends SupportedLength>(xs: Xs, maxLength: MaxLength) => xs is MaxLengthArray<MaxLength, Xs[number]> & Xs;
|
|
78
|
+
/**
|
|
79
|
+
* Type guard that checks if an array's length is within the inclusive range
|
|
80
|
+
* `[minLength, maxLength]`.
|
|
81
|
+
*
|
|
82
|
+
* **Type Narrowing Behavior:**
|
|
83
|
+
*
|
|
84
|
+
* - Narrows the input to `BoundedLengthArray<MinLength, MaxLength, E>` while
|
|
85
|
+
* preserving the original array type (e.g. tuple types) via intersection.
|
|
86
|
+
* - Since `BoundedLengthArray` is the intersection of `MinLengthArray` and
|
|
87
|
+
* `MaxLengthArray`, the narrowed value is assignable to both, and both
|
|
88
|
+
* bounds can be weakened independently.
|
|
89
|
+
* - The length constraint lives only in the brand, so this stays cheap for the
|
|
90
|
+
* type checker even when the element type is large — unlike
|
|
91
|
+
* `isBoundedLengthTuple`, which narrows to a union of tuple types.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
*
|
|
95
|
+
* ```ts
|
|
96
|
+
* const input: readonly number[] = [1, 2, 3];
|
|
97
|
+
*
|
|
98
|
+
* assert.isTrue(Arr.isBoundedLengthArray(input, 1, 5));
|
|
99
|
+
*
|
|
100
|
+
* assert.isFalse(Arr.isBoundedLengthArray([], 1, 5));
|
|
101
|
+
*
|
|
102
|
+
* if (Arr.isBoundedLengthArray(input, 1, 5)) {
|
|
103
|
+
* const selection: BoundedLengthArray<1, 5, number> = input;
|
|
104
|
+
*
|
|
105
|
+
* const relaxed: BoundedLengthArray<0, 100, number> = input; // OK ([1, 5] ⊆ [0, 100])
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
110
|
+
* @template MinLength - The minimum number of elements (inclusive).
|
|
111
|
+
* @template MaxLength - The maximum number of elements (inclusive).
|
|
112
|
+
* @param xs - The array to check.
|
|
113
|
+
* @param minLength - The minimum number of elements (inclusive).
|
|
114
|
+
* @param maxLength - The maximum number of elements (inclusive).
|
|
115
|
+
* @returns `true` if `minLength <= xs.length && xs.length <= maxLength`,
|
|
116
|
+
* `false` otherwise. When `true`, TypeScript narrows `xs` to
|
|
117
|
+
* `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.
|
|
118
|
+
*/
|
|
119
|
+
export declare const isBoundedLengthArray: <Xs extends readonly unknown[], MinLength extends SupportedLength, MaxLength extends SupportedLength>(xs: Xs, minLength: MinLength, maxLength: MaxLength) => xs is BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs;
|
|
120
|
+
/**
|
|
121
|
+
* Type guard that checks if an array has exactly `length` elements.
|
|
122
|
+
*
|
|
123
|
+
* **Type Narrowing Behavior:**
|
|
124
|
+
*
|
|
125
|
+
* - Narrows the input to `FixedLengthArray<Length, E>` while preserving the
|
|
126
|
+
* original array type (e.g. tuple types) via intersection.
|
|
127
|
+
* - Since `FixedLengthArray<Length, E>` is defined as
|
|
128
|
+
* `BoundedLengthArray<Length, Length, E>`, the narrowed value is assignable
|
|
129
|
+
* to any `MinLengthArray<N, E>` with `N <= Length` and any
|
|
130
|
+
* `MaxLengthArray<N, E>` with `N >= Length`.
|
|
131
|
+
* - The length constraint lives only in the brand, so this stays cheap for the
|
|
132
|
+
* type checker even when the element type is large — unlike
|
|
133
|
+
* `isFixedLengthTuple`, which narrows to a structural tuple type.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
*
|
|
137
|
+
* ```ts
|
|
138
|
+
* const input: readonly number[] = [255, 128, 0];
|
|
139
|
+
*
|
|
140
|
+
* assert.isTrue(Arr.isFixedLengthArray(input, 3));
|
|
141
|
+
*
|
|
142
|
+
* assert.isFalse(Arr.isFixedLengthArray(input, 4));
|
|
143
|
+
*
|
|
144
|
+
* if (Arr.isFixedLengthArray(input, 3)) {
|
|
145
|
+
* const rgb: FixedLengthArray<3, number> = input;
|
|
146
|
+
*
|
|
147
|
+
* const atMost5: MaxLengthArray<5, number> = input; // OK (3 <= 5)
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @template Xs - The input array type (tuple types are preserved).
|
|
152
|
+
* @template Length - The exact number of elements.
|
|
153
|
+
* @param xs - The array to check.
|
|
154
|
+
* @param length - The exact number of elements.
|
|
155
|
+
* @returns `true` if `xs.length === length`, `false` otherwise. When `true`,
|
|
156
|
+
* TypeScript narrows `xs` to `FixedLengthArray<Length, Xs[number]> & Xs`.
|
|
157
|
+
*/
|
|
158
|
+
export declare const isFixedLengthArray: <Xs extends readonly unknown[], Length extends SupportedLength>(xs: Xs, length: Length) => xs is FixedLengthArray<Length, Xs[number]> & Xs;
|
|
159
|
+
//# sourceMappingURL=array-utils-length-bounded-array-guard.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-guard.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-length-bounded-array-guard.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,EAAE,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA4B,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,GAC3B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,KACnB,EAAE,IAAI,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA4B,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,oBAAoB,GAC/B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,SAAS,SAAS,eAAe,EACjC,SAAS,SAAS,eAAe,MAE7B,EAAE,aACK,SAAS,aACT,SAAS,KACnB,EAAE,IAAI,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EACd,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,kBAAkB,GAC7B,EAAE,SAAS,SAAS,OAAO,EAAE,EAC7B,MAAM,SAAS,eAAe,MAE1B,EAAE,UACE,MAAM,KACb,EAAE,IAAI,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAA0B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const isMinLengthArray = (xs, minLength) => xs.length >= minLength;
|
|
2
|
+
const isMaxLengthArray = (xs, maxLength) => xs.length <= maxLength;
|
|
3
|
+
const isBoundedLengthArray = (xs, minLength, maxLength) => xs.length >= minLength && xs.length <= maxLength;
|
|
4
|
+
const isFixedLengthArray = (xs, length) => xs.length === length;
|
|
5
|
+
|
|
6
|
+
export { isBoundedLengthArray, isFixedLengthArray, isMaxLengthArray, isMinLengthArray };
|
|
7
|
+
//# sourceMappingURL=array-utils-length-bounded-array-guard.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils-length-bounded-array-guard.mjs","sources":["../../../src/array/impl/array-utils-length-bounded-array-guard.mts"],"sourcesContent":["import {\n type BoundedLengthArray,\n type FixedLengthArray,\n type MaxLengthArray,\n type MinLengthArray,\n type SupportedLength,\n} from 'ts-type-forge';\n\n/**\n * Type guard that checks if an array has at least `minLength` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `MinLengthArray<MinLength, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isMinLengthTuple`, which narrows to a structural tuple type.\n * - The result participates in the length-constraint subtyping relation: for\n * example, a value narrowed to `MinLengthArray<3, E>` is assignable to\n * `MinLengthArray<1, E>`.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [0, 1, 2, 3];\n *\n * assert.isTrue(Arr.isMinLengthArray(input, 3));\n *\n * assert.isFalse(Arr.isMinLengthArray([0], 3));\n *\n * if (Arr.isMinLengthArray(input, 3)) {\n * const history: MinLengthArray<3, number> = input;\n *\n * const nonEmpty: MinLengthArray<1, number> = input; // OK (3 >= 1)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @param xs - The array to check.\n * @param minLength - The minimum number of elements (inclusive).\n * @returns `true` if `xs.length >= minLength`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `MinLengthArray<MinLength, Xs[number]> & Xs`.\n */\nexport const isMinLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n): xs is MinLengthArray<MinLength, Xs[number]> & Xs => xs.length >= minLength;\n\n/**\n * Type guard that checks if an array has at most `maxLength` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `MaxLengthArray<MaxLength, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isMaxLengthTuple`, which narrows to a union of tuple types.\n * - The result participates in the length-constraint subtyping relation: for\n * example, a value narrowed to `MaxLengthArray<8, E>` is assignable to\n * `MaxLengthArray<16, E>`.\n *\n * @example\n *\n * ```ts\n * const input: readonly string[] = ['a', 'b', 'c'];\n *\n * assert.isTrue(Arr.isMaxLengthArray(input, 8));\n *\n * assert.isFalse(Arr.isMaxLengthArray(input, 2));\n *\n * if (Arr.isMaxLengthArray(input, 8)) {\n * const tags: MaxLengthArray<8, string> = input;\n *\n * const relaxed: MaxLengthArray<16, string> = input; // OK (8 <= 16)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to check.\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `true` if `xs.length <= maxLength`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `MaxLengthArray<MaxLength, Xs[number]> & Xs`.\n */\nexport const isMaxLengthArray = <\n Xs extends readonly unknown[],\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n maxLength: MaxLength,\n): xs is MaxLengthArray<MaxLength, Xs[number]> & Xs => xs.length <= maxLength;\n\n/**\n * Type guard that checks if an array's length is within the inclusive range\n * `[minLength, maxLength]`.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `BoundedLengthArray<MinLength, MaxLength, E>` while\n * preserving the original array type (e.g. tuple types) via intersection.\n * - Since `BoundedLengthArray` is the intersection of `MinLengthArray` and\n * `MaxLengthArray`, the narrowed value is assignable to both, and both\n * bounds can be weakened independently.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isBoundedLengthTuple`, which narrows to a union of tuple types.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [1, 2, 3];\n *\n * assert.isTrue(Arr.isBoundedLengthArray(input, 1, 5));\n *\n * assert.isFalse(Arr.isBoundedLengthArray([], 1, 5));\n *\n * if (Arr.isBoundedLengthArray(input, 1, 5)) {\n * const selection: BoundedLengthArray<1, 5, number> = input;\n *\n * const relaxed: BoundedLengthArray<0, 100, number> = input; // OK ([1, 5] ⊆ [0, 100])\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template MinLength - The minimum number of elements (inclusive).\n * @template MaxLength - The maximum number of elements (inclusive).\n * @param xs - The array to check.\n * @param minLength - The minimum number of elements (inclusive).\n * @param maxLength - The maximum number of elements (inclusive).\n * @returns `true` if `minLength <= xs.length && xs.length <= maxLength`,\n * `false` otherwise. When `true`, TypeScript narrows `xs` to\n * `BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs`.\n */\nexport const isBoundedLengthArray = <\n Xs extends readonly unknown[],\n MinLength extends SupportedLength,\n MaxLength extends SupportedLength,\n>(\n xs: Xs,\n minLength: MinLength,\n maxLength: MaxLength,\n): xs is BoundedLengthArray<MinLength, MaxLength, Xs[number]> & Xs =>\n xs.length >= minLength && xs.length <= maxLength;\n\n/**\n * Type guard that checks if an array has exactly `length` elements.\n *\n * **Type Narrowing Behavior:**\n *\n * - Narrows the input to `FixedLengthArray<Length, E>` while preserving the\n * original array type (e.g. tuple types) via intersection.\n * - Since `FixedLengthArray<Length, E>` is defined as\n * `BoundedLengthArray<Length, Length, E>`, the narrowed value is assignable\n * to any `MinLengthArray<N, E>` with `N <= Length` and any\n * `MaxLengthArray<N, E>` with `N >= Length`.\n * - The length constraint lives only in the brand, so this stays cheap for the\n * type checker even when the element type is large — unlike\n * `isFixedLengthTuple`, which narrows to a structural tuple type.\n *\n * @example\n *\n * ```ts\n * const input: readonly number[] = [255, 128, 0];\n *\n * assert.isTrue(Arr.isFixedLengthArray(input, 3));\n *\n * assert.isFalse(Arr.isFixedLengthArray(input, 4));\n *\n * if (Arr.isFixedLengthArray(input, 3)) {\n * const rgb: FixedLengthArray<3, number> = input;\n *\n * const atMost5: MaxLengthArray<5, number> = input; // OK (3 <= 5)\n * }\n * ```\n *\n * @template Xs - The input array type (tuple types are preserved).\n * @template Length - The exact number of elements.\n * @param xs - The array to check.\n * @param length - The exact number of elements.\n * @returns `true` if `xs.length === length`, `false` otherwise. When `true`,\n * TypeScript narrows `xs` to `FixedLengthArray<Length, Xs[number]> & Xs`.\n */\nexport const isFixedLengthArray = <\n Xs extends readonly unknown[],\n Length extends SupportedLength,\n>(\n xs: Xs,\n length: Length,\n): xs is FixedLengthArray<Length, Xs[number]> & Xs => xs.length === length;\n"],"names":[],"mappings":"AA6CO,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KACqD,GAAG,MAAA,IAAU;AAuC7D,MAAM,gBAAA,GAAmB,CAI9B,EAAA,EACA,SAAA,KACqD,GAAG,MAAA,IAAU;AA2C7D,MAAM,oBAAA,GAAuB,CAKlC,EAAA,EACA,SAAA,EACA,cAEA,EAAA,CAAG,MAAA,IAAU,SAAA,IAAa,EAAA,CAAG,MAAA,IAAU;AAwClC,MAAM,kBAAA,GAAqB,CAIhC,EAAA,EACA,MAAA,KACoD,GAAG,MAAA,KAAW;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FixedLengthTuple, type Increment, type IsFixedLengthList, type NonEmptyArray, type NonEmptyTuple } from 'ts-type-forge';
|
|
2
2
|
import { type ArgArrayIndex, type ArgArrayIndexWithNegative, type SizeType } from '../../types.mjs';
|
|
3
3
|
/**
|
|
4
4
|
* Returns a new array with an element at the specified index replaced.
|
|
@@ -15,10 +15,10 @@ import { type ArgArrayIndex, type ArgArrayIndexWithNegative, type SizeType } fro
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function set<const Ar extends readonly unknown[], const V = Ar[number]>(array: Ar, index: ArgArrayIndex<Ar>, newValue: V): IsFixedLengthList<Ar> extends true ? Readonly<{
|
|
17
17
|
[K in keyof Ar]: Ar[K] | V;
|
|
18
|
-
}> : Ar extends
|
|
18
|
+
}> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<Ar[number] | V> : readonly (Ar[number] | V)[];
|
|
19
19
|
export declare function set<const V>(index: SizeType.ArgArr, newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ? Readonly<{
|
|
20
20
|
[K in keyof Ar]: Ar[K] | V;
|
|
21
|
-
}> : Ar extends
|
|
21
|
+
}> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<Ar[number] | V> : readonly (Ar[number] | V)[];
|
|
22
22
|
/**
|
|
23
23
|
* Returns a new array with an element at the specified index updated by applying a function.
|
|
24
24
|
*
|
|
@@ -41,10 +41,10 @@ export declare function set<const V>(index: SizeType.ArgArr, newValue: V): <cons
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function toUpdated<const Ar extends readonly unknown[], const V = Ar[number]>(array: Ar, index: ArgArrayIndex<Ar>, updater: (prev: Ar[number]) => V): IsFixedLengthList<Ar> extends true ? Readonly<{
|
|
43
43
|
[K in keyof Ar]: Ar[K] | V;
|
|
44
|
-
}> : Ar extends
|
|
44
|
+
}> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<Ar[number] | V> : readonly (Ar[number] | V)[];
|
|
45
45
|
export declare function toUpdated<E, const V = E>(index: SizeType.ArgArr, updater: (prev: E) => V): <const Ar extends readonly E[]>(array: Ar) => IsFixedLengthList<Ar> extends true ? Readonly<{
|
|
46
46
|
[K in keyof Ar]: Ar[K] | V;
|
|
47
|
-
}> : Ar extends
|
|
47
|
+
}> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<Ar[number] | V> : readonly (Ar[number] | V)[];
|
|
48
48
|
/**
|
|
49
49
|
* Returns a new array with a value inserted at the specified index.
|
|
50
50
|
*
|
|
@@ -62,8 +62,8 @@ export declare function toUpdated<E, const V = E>(index: SizeType.ArgArr, update
|
|
|
62
62
|
* assert.deepStrictEqual(appendFive, [1, 2, 4, 5]);
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
export declare function toInserted<const Ar extends readonly unknown[], const V = Ar[number]>(array: Ar, index: ArgArrayIndexWithNegative<Ar>, newValue: V): IsFixedLengthList<Ar> extends true ?
|
|
66
|
-
export declare function toInserted<const V>(index: SizeType.ArgArrWithNegative, newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ?
|
|
65
|
+
export declare function toInserted<const Ar extends readonly unknown[], const V = Ar[number]>(array: Ar, index: ArgArrayIndexWithNegative<Ar>, newValue: V): IsFixedLengthList<Ar> extends true ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V> : NonEmptyArray<Ar[number] | V>;
|
|
66
|
+
export declare function toInserted<const V>(index: SizeType.ArgArrWithNegative, newValue: V): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ? FixedLengthTuple<CastToNumber<Increment<Ar['length']>>, Ar[number] | V> : NonEmptyArray<Ar[number] | V>;
|
|
67
67
|
type CastToNumber<T> = T extends number ? T : never;
|
|
68
68
|
/**
|
|
69
69
|
* Returns a new array with the element at the specified index removed.
|
|
@@ -139,8 +139,8 @@ export declare function toUnshifted<const V>(newValue: V): <const Ar extends rea
|
|
|
139
139
|
* assert.deepStrictEqual(filledCurried, ['x', 'x', 'x']);
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
|
-
export declare function toFilled<const Ar extends readonly unknown[], const V>(array: Ar, value: V): IsFixedLengthList<Ar> extends true ?
|
|
143
|
-
export declare function toFilled<const V>(value: V): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ?
|
|
142
|
+
export declare function toFilled<const Ar extends readonly unknown[], const V>(array: Ar, value: V): IsFixedLengthList<Ar> extends true ? FixedLengthTuple<Ar['length'], V> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<V> : readonly V[];
|
|
143
|
+
export declare function toFilled<const V>(value: V): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ? FixedLengthTuple<Ar['length'], V> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<V> : readonly V[];
|
|
144
144
|
/**
|
|
145
145
|
* Returns a new array with elements in the specified range replaced by the specified value.
|
|
146
146
|
*
|
|
@@ -161,10 +161,10 @@ export declare function toFilled<const V>(value: V): <const Ar extends readonly
|
|
|
161
161
|
export declare function toRangeFilled<const Ar extends readonly unknown[], const V>(array: Ar, value: V, fillRange: readonly [
|
|
162
162
|
start: ArgArrayIndexWithNegative<Ar>,
|
|
163
163
|
end: ArgArrayIndexWithNegative<Ar>
|
|
164
|
-
]): IsFixedLengthList<Ar> extends true ?
|
|
164
|
+
]): IsFixedLengthList<Ar> extends true ? FixedLengthTuple<Ar['length'], V | Ar[number]> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<V | Ar[number]> : readonly (V | Ar[number])[];
|
|
165
165
|
export declare function toRangeFilled<const V>(value: V, fillRange: readonly [
|
|
166
166
|
start: SizeType.ArgArrWithNegative,
|
|
167
167
|
end: SizeType.ArgArrWithNegative
|
|
168
|
-
]): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ?
|
|
168
|
+
]): <const Ar extends readonly unknown[]>(array: Ar) => IsFixedLengthList<Ar> extends true ? FixedLengthTuple<Ar['length'], V | Ar[number]> : Ar extends NonEmptyTuple<unknown> ? NonEmptyArray<V | Ar[number]> : readonly (V | Ar[number])[];
|
|
169
169
|
export {};
|
|
170
170
|
//# sourceMappingURL=array-utils-modification.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-modification.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-modification.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"array-utils-modification.d.mts","sourceRoot":"","sources":["../../../src/array/impl/array-utils-modification.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAC3E,KAAK,EAAE,EAAE,EACT,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,EACxB,QAAQ,EAAE,CAAC,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