ts-toolbelt
Advanced tools
Comparing version 0.0.16 to 1.0.0
@@ -1,6 +0,3 @@ | ||
/** Describes a **tuple** or an **`Array`** | ||
*/ | ||
export declare type List<A = any> = A[]; | ||
/** Describes how to perform iterations | ||
*/ | ||
export declare type Way = '->' | '<-'; |
@@ -1,2 +0,3 @@ | ||
export * from './Cast'; | ||
export { Cast } from './Cast'; | ||
export { Compute } from './Compute'; | ||
export { Equals } from './Equals'; | ||
@@ -7,1 +8,2 @@ export { Extends } from './Extends'; | ||
export { Type } from './Type'; | ||
export { x } from './x'; |
export { Arrow } from './Arrow'; | ||
export { ClassOf } from './ClassOf'; | ||
export { Composer, Compose } from './Compose'; | ||
export { Gap, Curry } from './Curry'; | ||
export { Curry } from './Curry'; | ||
export { ParamsOf } from './ParamsOf'; | ||
export { Piper, Pipe } from './Pipe'; | ||
export { ReturnOf } from './ReturnOf'; |
@@ -1,2 +0,1 @@ | ||
import { List } from '../_Internal'; | ||
/** Alias to create a **`Function`** | ||
@@ -8,2 +7,2 @@ * @param P parameters | ||
*/ | ||
export declare type Arrow<P extends List = any, R extends any = any> = (...args: P) => R; | ||
export declare type Arrow<P extends any[] = any, R extends any = any> = (...args: P) => R; |
@@ -8,20 +8,18 @@ import { Pos } from '../Iteration/Pos'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Type } from '../Any/Type'; | ||
import { Arrow } from './Arrow'; | ||
import { Equals } from '../Any/Equals'; | ||
import { ParamsOf } from './ParamsOf'; | ||
import { ReturnOf } from './ReturnOf'; | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Key } from '../Iteration/Key'; | ||
import { NonNullable } from '../Tuple/NonNullable'; | ||
import { List } from '../_Internal'; | ||
export declare type Gap = Type<never, 'gap'>; | ||
declare type GapOf<T1 extends List, T2 extends List, TN extends List, I extends Iteration = IterationOf<'0'>> = Equals<T1[Pos<I>], Gap> extends true ? Append<TN, T2[Pos<I>]> : TN; | ||
declare type _GapsOf<T1 extends List, T2 extends List, TN extends List = [], I extends Iteration = IterationOf<'0'>> = { | ||
import { x } from '../Any/x'; | ||
declare type GapOf<T1 extends any[], T2 extends any[], TN extends any[], I extends Iteration = IterationOf<'0'>> = T1[Pos<I>] extends x ? Append<TN, T2[Pos<I>]> : TN; | ||
declare type _GapsOf<T1 extends any[], T2 extends any[], TN extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _GapsOf<T1, T2, GapOf<T1, T2, TN, I>, Next<I>>; | ||
1: Concat<TN, Drop<T2, Key<I>>>; | ||
}[Pos<I> extends Length<T1> ? 1 : 0]; | ||
declare type GapsOf<T1 extends List, T2 extends List> = _GapsOf<T1, T2> extends infer X ? Cast<X, List> : never; | ||
declare type Gaps<T extends List> = NonNullable<{ | ||
[K in keyof T]?: T[K] | Gap; | ||
declare type GapsOf<T1 extends any[], T2 extends any[]> = _GapsOf<T1, T2> extends infer X ? Cast<X, any[]> : never; | ||
declare type Gaps<T extends any[]> = NonNullable<{ | ||
[K in keyof T]?: T[K] | x; | ||
}>; | ||
@@ -33,3 +31,3 @@ /** Curry a **`Function`** like **`curry()`** | ||
*/ | ||
export declare type Curry<F extends Arrow> = <T extends List>(...args: Cast<T, Gaps<ParamsOf<F>>>) => GapsOf<T, ParamsOf<F>> extends [any, ...List] ? Curry<(...args: GapsOf<T, ParamsOf<F>>) => ReturnOf<F>> : ReturnOf<F>; | ||
export declare type Curry<F extends Arrow> = <T extends any[]>(...args: Cast<T, Gaps<ParamsOf<F>>>) => GapsOf<T, ParamsOf<F>> extends [any, ...any[]] ? Curry<(...args: GapsOf<T, ParamsOf<F>>) => ReturnOf<F>> : ReturnOf<F>; | ||
export {}; |
import { Arrow } from './Arrow'; | ||
/** Extract parameters from a **`Function`** | ||
* @param F to extract from | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type ParamsOf<F extends Arrow> = F extends ((...args: infer T) => any) ? T : never; |
import { Arrow } from './Arrow'; | ||
import { List } from '../_Internal'; | ||
/** Extract the return type of a **`Function`** | ||
@@ -8,2 +7,2 @@ * @param F to extract from | ||
*/ | ||
export declare type ReturnOf<F extends Arrow> = F extends ((...args: List) => infer R) ? R : never; | ||
export declare type ReturnOf<F extends Arrow> = F extends ((...args: any[]) => infer R) ? R : never; |
@@ -0,1 +1,3 @@ | ||
export { Fmt } from './Fmt'; | ||
export { Iteration } from './Iteration'; | ||
export { IterationOf } from './IterationOf'; | ||
@@ -2,0 +4,0 @@ export { Key } from './Key'; |
@@ -89,11 +89,3 @@ import { Nbr } from '../Number/_Internal'; | ||
}; | ||
/** Describes a valid entry of **`IterationMap`** | ||
* - `[0]`: Previous | ||
* - `[1]`: Next | ||
* - `[2]`: Current **`string`** | ||
* - `[3]`: Current **`number`** | ||
* - `[4]`: Sign (- / 0 / +) | ||
*/ | ||
export declare type Iteration = [keyof IterationMap, keyof IterationMap, string, number, '-' | '0' | '+']; | ||
/** Transform a**number**to an **`Iteration`** | ||
/** Transform a **number** to an **`Iteration`** | ||
* (to use **`Prev`**, **`Next`**, & **`Pos`**) | ||
@@ -100,0 +92,0 @@ * @param N to transform |
@@ -1,9 +0,8 @@ | ||
import { Iteration } from './IterationOf'; | ||
import { FormatMap, Format } from './_Internal'; | ||
import { Iteration } from './Iteration'; | ||
import { FormatMap } from './_Internal'; | ||
/** Get the position of **`I`** (**string**) | ||
* @param I to query | ||
* @param fmt output (?=`'s'`) | ||
* @returns **`string`** | ||
* @example | ||
*/ | ||
export declare type Key<I extends Iteration, fmt extends Format = 's'> = I[FormatMap[fmt]]; | ||
export declare type Key<I extends Iteration> = I[FormatMap['s']]; |
@@ -1,2 +0,3 @@ | ||
import { IterationMap, Iteration } from './IterationOf'; | ||
import { IterationMap } from './IterationOf'; | ||
import { Iteration } from './Iteration'; | ||
/** Move **`I`**'s position forward | ||
@@ -3,0 +4,0 @@ * @param I to move |
@@ -1,9 +0,8 @@ | ||
import { Iteration } from './IterationOf'; | ||
import { Format, FormatMap } from './_Internal'; | ||
import { Iteration } from './Iteration'; | ||
import { FormatMap } from './_Internal'; | ||
/** Get the position of **`I`** (**number**) | ||
* @param I to query | ||
* @param fmt output (?=`'n'`) | ||
* @returns **`number`** | ||
* @example | ||
*/ | ||
export declare type Pos<I extends Iteration, fmt extends Format = 'n'> = I[FormatMap[fmt]]; | ||
export declare type Pos<I extends Iteration> = I[FormatMap['n']]; |
@@ -1,2 +0,3 @@ | ||
import { IterationMap, Iteration } from './IterationOf'; | ||
import { IterationMap } from './IterationOf'; | ||
import { Iteration } from './Iteration'; | ||
/** Move **`I`**'s position backwards | ||
@@ -3,0 +4,0 @@ * @param I to move |
import { _Negate } from './Negate'; | ||
import { _IsNegative } from './IsNegative'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Nbr } from './_Internal'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
export declare type _Absolute<N extends Iteration> = _IsNegative<N> extends true ? _Negate<N> : N; | ||
@@ -15,2 +16,2 @@ /** Get the absolute value of a **number** | ||
*/ | ||
export declare type Absolute<N extends Nbr, fmt extends Format = 's'> = _Absolute<IterationOf<N>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Absolute<N extends Nbr, fmt extends Format = 's'> = _Absolute<IterationOf<N>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -3,0 +4,0 @@ import { Equals } from '../Any/Equals'; |
import { _Greater } from './Greater'; | ||
import { _Lower } from './Lower'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Nbr } from './_Internal'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type _Clamp<N extends Iteration, Min extends Iteration, Max extends Iteration> = _Greater<N, Max> extends true ? Max : _Lower<N, Min> extends true ? Min : N; | ||
@@ -18,3 +19,3 @@ /** Keep a **number** within a range of **number**s | ||
*/ | ||
export declare type Clamp<N extends Nbr, Min extends Nbr, Max extends Nbr, fmt extends Format = 's'> = _Clamp<IterationOf<N>, IterationOf<Min>, IterationOf<Max>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Clamp<N extends Nbr, Min extends Nbr, Max extends Nbr, fmt extends Format = 's'> = _Clamp<IterationOf<N>, IterationOf<Min>, IterationOf<Max>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; | ||
export {}; |
import { _Minus } from './Minus'; | ||
import { _IsPositive } from './IsPositive'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -6,0 +7,0 @@ export declare type _Greater<N1 extends Iteration, N2 extends Iteration> = _Minus<N1, N2> extends infer M ? _IsPositive<Cast<M, Iteration>> : never; |
import { Equals } from '../Any/Equals'; | ||
import { _Greater } from './Greater'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -5,0 +6,0 @@ import { Cast } from '../Any/Cast'; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -3,0 +4,0 @@ import { Extends } from '../Any/Extends'; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -3,0 +4,0 @@ import { Extends } from '../Any/Extends'; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -3,0 +4,0 @@ import { Extends } from '../Any/Extends'; |
import { _Greater } from './Greater'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -4,0 +5,0 @@ import { Cast } from '../Any/Cast'; |
import { _GreaterEq } from './GreaterEq'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from './_Internal'; | ||
@@ -4,0 +5,0 @@ import { Cast } from '../Any/Cast'; |
@@ -1,4 +0,4 @@ | ||
import { Equals } from '../Any/Equals'; | ||
import { Prev } from '../Iteration/Prev'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Next } from '../Iteration/Next'; | ||
@@ -11,7 +11,7 @@ import { Nbr, Numbers } from './_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type MaxPositive<N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: MaxPositive<Exclude<N, Key<I>>, Next<I>>; | ||
1: Prev<I>; | ||
}[Equals<N, never> extends true ? 1 : 0]; | ||
}[[N] extends [never] ? 1 : 0]; | ||
declare type MaxNegative<N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
@@ -28,3 +28,3 @@ 0: MaxNegative<Exclude<N, Key<I>>, Prev<I>>; | ||
*/ | ||
export declare type Max<N extends Nbr, fmt extends Format = 's'> = _Max<IterationOf<N>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Max<N extends Nbr, fmt extends Format = 's'> = _Max<IterationOf<N>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
import { Pos } from '../Iteration/Pos'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Next } from '../Iteration/Next'; | ||
@@ -9,13 +9,13 @@ import { Nbr, Numbers } from './_Internal'; | ||
import { Prev } from '../Iteration/Prev'; | ||
import { Equals } from '../Any/Equals'; | ||
import { _IsPositive } from './IsPositive'; | ||
import { Exclude } from '../Union/Exclude'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type MinPositive<N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: MinPositive<N, Next<I>>; | ||
1: I; | ||
}[N extends Key<I> ? 1 : 0]; | ||
}[Key<I> extends N ? 1 : 0]; | ||
declare type MinNegative<N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: MinNegative<Exclude<N, Key<I>>, Prev<I>>; | ||
1: Next<I>; | ||
}[Equals<N, never> extends true ? 1 : 0]; | ||
}[[N] extends [never] ? 1 : 0]; | ||
export declare type _Min<N extends Iteration> = _IsPositive<N> extends true ? MinPositive<Key<N>> : MinNegative<Exclude<Key<N>, Numbers['string']['+']>>; | ||
@@ -28,3 +28,3 @@ /** Get the smallest **number** within an **union** | ||
*/ | ||
export declare type Min<N extends Nbr, fmt extends Format = 's'> = _Min<IterationOf<N>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Min<N extends Nbr, fmt extends Format = 's'> = _Min<IterationOf<N>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; | ||
export {}; |
@@ -1,2 +0,3 @@ | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Pos } from '../Iteration/Pos'; | ||
@@ -9,2 +10,3 @@ import { Prev } from '../Iteration/Prev'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type MinusPositive<N1 extends Iteration, N2 extends Iteration> = { | ||
@@ -28,3 +30,3 @@ 0: MinusPositive<Prev<N1>, Prev<N2>>; | ||
*/ | ||
export declare type Minus<N1 extends Nbr, N2 extends Nbr, fmt extends Format = 's'> = _Minus<IterationOf<N1>, IterationOf<N2>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Minus<N1 extends Nbr, N2 extends Nbr, fmt extends Format = 's'> = _Minus<IterationOf<N1>, IterationOf<N2>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; | ||
export {}; |
import { _Minus } from './Minus'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Nbr } from './_Internal'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
export declare type _Negate<N extends Iteration> = _Minus<IterationOf<'0'>, N>; | ||
@@ -14,2 +15,2 @@ /** Negate a **number** | ||
*/ | ||
export declare type Negate<N extends Nbr, fmt extends Format = 's'> = _Negate<IterationOf<N>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Negate<N extends Nbr, fmt extends Format = 's'> = _Negate<IterationOf<N>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; |
@@ -1,2 +0,3 @@ | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Pos } from '../Iteration/Pos'; | ||
@@ -9,2 +10,3 @@ import { Prev } from '../Iteration/Prev'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type PlusPositive<N1 extends Iteration, N2 extends Iteration> = { | ||
@@ -28,3 +30,3 @@ 0: PlusPositive<Next<N1>, Prev<N2>>; | ||
*/ | ||
export declare type Plus<N1 extends Nbr, N2 extends Nbr, fmt extends Format = 's'> = _Plus<IterationOf<N1>, IterationOf<N2>> extends infer I ? Pos<Cast<I, Iteration>, fmt> : never; | ||
export declare type Plus<N1 extends Nbr, N2 extends Nbr, fmt extends Format = 's'> = _Plus<IterationOf<N1>, IterationOf<N2>> extends infer I ? Fmt<Cast<I, Iteration>, fmt> : never; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Prepend } from '../Tuple/Prepend'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { Prev } from '../Iteration/Prev'; | ||
@@ -10,9 +10,9 @@ import { Next } from '../Iteration/Next'; | ||
import { Way } from '../_Internal'; | ||
import { List } from '../_Internal'; | ||
declare type RangeForth<From extends Iteration, To extends Iteration, fmt extends Format = 's', T extends List = []> = { | ||
0: RangeForth<Prev<From>, To, fmt, Prepend<T, Pos<From, fmt>>>; | ||
import { Fmt } from '../Iteration/Fmt'; | ||
declare type RangeForth<From extends Iteration, To extends Iteration, fmt extends Format = 's', T extends any[] = []> = { | ||
0: RangeForth<Prev<From>, To, fmt, Prepend<T, Fmt<From, fmt>>>; | ||
1: T; | ||
}[From extends To ? 1 : 0]; | ||
declare type RangeBack<From extends Iteration, To extends Iteration, fmt extends Format = 's', T extends List = []> = { | ||
0: RangeBack<Next<From>, To, fmt, Prepend<T, Pos<From, fmt>>>; | ||
declare type RangeBack<From extends Iteration, To extends Iteration, fmt extends Format = 's', T extends any[] = []> = { | ||
0: RangeBack<Next<From>, To, fmt, Prepend<T, Fmt<From, fmt>>>; | ||
1: T; | ||
@@ -29,6 +29,9 @@ }[From extends To ? 1 : 0]; | ||
* @param fmt output (?=`'s'`) | ||
* @returns **`(number | string)[]`** | ||
* @returns **`string[]`** or **`number[]`** | ||
* @example | ||
*/ | ||
export declare type Range<From extends Nbr, To extends Nbr, way extends Way = '->', fmt extends Format = 's'> = _Range<IterationOf<From>, IterationOf<To>, way, fmt> extends infer X ? Cast<X, List> : never; | ||
export declare type Range<From extends Nbr, To extends Nbr, way extends Way = '->', fmt extends Format = 's'> = _Range<IterationOf<From>, IterationOf<To>, way, fmt> extends infer X ? Cast<X, { | ||
s: string[]; | ||
n: number[]; | ||
}[fmt]> : never; | ||
export {}; |
@@ -15,2 +15,3 @@ export { At } from './At'; | ||
export { MergeKeys } from './MergeKeys'; | ||
export { Modify } from './Modify'; | ||
export { NonNullable } from './NonNullable'; | ||
@@ -17,0 +18,0 @@ export { NonNullableKeys } from './NonNullableKeys'; |
import { Merge } from './Merge'; | ||
import { Exclude } from './Exclude'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Get an **`object`** that is the difference between **`O`** & **`O1`** | ||
@@ -13,2 +14,2 @@ * (**`O`**'s differences have priority over **`O1`**'s if fields overlap) | ||
*/ | ||
export declare type Diff<O extends object, O1 extends object, match extends Match = 'default'> = Merge<Exclude<O, O1, match>, Exclude<O1, O, match>>; | ||
export declare type Diff<O extends object, O1 extends object, match extends Match = 'default'> = Merge<Exclude<O, O1, match>, Exclude<O1, O, match>> extends infer X ? Cast<X, object> : never; |
import { ExcludeKeys } from './ExcludeKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Pick } from './Pick'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Exclude the fields of **`O1`** out of **`O`** | ||
@@ -12,2 +13,2 @@ * (If `match = 'default'`, no type checks are done) | ||
*/ | ||
export declare type Exclude<O extends object, O1 extends object, match extends Match = 'default'> = Pick<O, ExcludeKeys<O, O1, match>>; | ||
export declare type Exclude<O extends object, O1 extends object, match extends Match = 'default'> = Pick<O, ExcludeKeys<O, O1, match>> extends infer X ? Cast<X, object> : never; |
import { FilterKeys } from './FilterKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Pick } from './Pick'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Filter out of **`O`** the fields that match **`M`** | ||
@@ -11,2 +12,2 @@ * @param O to remove from | ||
*/ | ||
export declare type Filter<O extends object, M extends any, match extends Match = 'default'> = Pick<O, FilterKeys<O, M, match>>; | ||
export declare type Filter<O extends object, M extends any, match extends Match = 'default'> = Pick<O, FilterKeys<O, M, match>> extends infer X ? Cast<X, object> : never; |
import { Match } from '../Any/_Internal'; | ||
import { Is } from '../Any/Is'; | ||
import { At } from './At'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Check whether **`O`** has a field of key **`K`** that matches **`M`** | ||
@@ -12,2 +13,2 @@ * @param O to be inspected | ||
*/ | ||
export declare type Has<O extends object, K extends string, M extends any = any, match extends Match = 'default'> = Is<At<O, K>, M, match>; | ||
export declare type Has<O extends object, K extends string, M extends any = any, match extends Match = 'default'> = Is<At<O, K>, M, match> extends infer X ? Cast<X, boolean> : never; |
import { Match } from '../Any/_Internal'; | ||
import { Path as OPath } from './Path'; | ||
import { Is } from '../Any/Is'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Check whether **`O`** has nested properties that match **`M`** | ||
@@ -12,2 +13,2 @@ * @param O to be inspected | ||
*/ | ||
export declare type HasPath<O extends object, Path extends string[], M extends any = any, match extends Match = 'default'> = Is<OPath<O, Path>, M, match>; | ||
export declare type HasPath<O extends object, Path extends string[], M extends any = any, match extends Match = 'default'> = Is<OPath<O, Path>, M, match> extends infer X ? Cast<X, boolean> : never; |
import { SelectKeys } from './SelectKeys'; | ||
import { Equals } from '../Any/Equals'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Not } from '../Boolean/Not'; | ||
/** Check whether **`O`** has fields that match **`M`** | ||
@@ -12,2 +10,2 @@ * @param O to be inspected | ||
*/ | ||
export declare type Includes<O extends object, M extends any, match extends Match = 'default'> = Not<Equals<SelectKeys<O, M, match>, never>>; | ||
export declare type Includes<O extends object, M extends any, match extends Match = 'default'> = [SelectKeys<O, M, match>] extends [never] ? false : true; |
import { IntersectKeys } from './IntersectKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Pick } from './Pick'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Get the intersecting fields of **`O`** & **`O1`** | ||
@@ -11,2 +12,2 @@ * (If `match = 'default'`, no type checks are done) | ||
*/ | ||
export declare type Intersect<O extends object, O1 extends object, match extends Match = 'default'> = Pick<O, IntersectKeys<O, O1, match>>; | ||
export declare type Intersect<O extends object, O1 extends object, match extends Match = 'default'> = Pick<O, IntersectKeys<O, O1, match>> extends infer X ? Cast<X, object> : never; |
import { Omit } from './Omit'; | ||
import { Compute } from '../Extras/Compute'; | ||
import { Compute } from '../Any/Compute'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Complete the fields of **`O`** with the ones of **`O1`** | ||
@@ -9,2 +10,2 @@ * @param O to complete | ||
*/ | ||
export declare type Merge<O extends object, O1 extends object> = Compute<O & Omit<O1, keyof O>>; | ||
export declare type Merge<O extends object, O1 extends object> = Compute<O & Omit<O1, keyof O>> extends infer X ? Cast<X, object> : never; |
import { Merge } from './Merge'; | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Depth } from './_Internal'; | ||
@@ -11,3 +10,3 @@ import { Pick } from './Pick'; | ||
declare type NonNullableDeep<O> = { | ||
[K in keyof O]: Extends<UNonNullable<O[K]>, object> extends true ? NonNullableDeep<O[K]> : UNonNullable<O[K]>; | ||
[K in keyof O]: NonNullableDeep<UNonNullable<O[K]>>; | ||
}; | ||
@@ -14,0 +13,0 @@ declare type NonNullablePart<O extends object, depth extends Depth> = { |
import { Merge } from './Merge'; | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Nullable as UNullable } from '../Union/Nullable'; | ||
import { Depth } from './_Internal'; | ||
@@ -8,6 +7,6 @@ import { Pick } from './Pick'; | ||
declare type NullableFlat<O> = { | ||
[K in keyof O]: O[K] | undefined; | ||
[K in keyof O]: UNullable<O[K]>; | ||
}; | ||
declare type NullableDeep<O> = { | ||
[K in keyof O]: Extends<UNonNullable<O[K]>, object> extends true ? NullableDeep<O[K]> : O[K] | undefined; | ||
[K in keyof O]: NullableDeep<UNullable<O[K]>>; | ||
}; | ||
@@ -14,0 +13,0 @@ declare type NullablePart<O extends object, depth extends Depth> = { |
import { Pick } from './Pick'; | ||
import { Exclude } from '../Union/Exclude'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Remove out of **`O`** the fields of key **`K`** | ||
@@ -9,2 +10,2 @@ * @param O to remove from | ||
*/ | ||
export declare type Omit<O extends object, K extends string> = Pick<O, Exclude<keyof O, K>>; | ||
export declare type Omit<O extends object, K extends string> = Pick<O, Exclude<keyof O, K>> extends infer X ? Cast<X, object> : never; |
import { Merge } from './Merge'; | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Pick } from './Pick'; | ||
@@ -11,3 +9,3 @@ import { Depth } from './_Internal'; | ||
declare type OptionalDeep<O> = { | ||
[K in keyof O]?: Extends<UNonNullable<O[K]>, object> extends true ? OptionalDeep<O[K]> : O[K]; | ||
[K in keyof O]?: OptionalDeep<O[K]>; | ||
}; | ||
@@ -14,0 +12,0 @@ declare type OptionalPart<O extends object, depth extends Depth> = { |
@@ -1,8 +0,11 @@ | ||
import { Merge } from './Merge'; | ||
import { At } from './At'; | ||
/** Update the fields of **`O`** with the ones of **`O1`** | ||
* @param O to complete | ||
* @param O1 to copy from | ||
* (only the existing fields will be updated) | ||
* @param O to update | ||
* @param O1 to update with | ||
* @returns **`object`** | ||
* @example | ||
*/ | ||
export declare type Overwrite<O extends object, O1 extends object> = Merge<O1, O>; | ||
export declare type Overwrite<O extends object, O1 extends object> = { | ||
[K in keyof O]: At<O1, K>; | ||
}; |
import { Merge as OMerge } from '../Merge'; | ||
import { Length } from '../../Tuple/Length'; | ||
import { Compute } from '../../Extras/Compute'; | ||
import { Iteration, IterationOf } from '../../Iteration/IterationOf'; | ||
import { Compute } from '../../Any/Compute'; | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Path as PPath } from './_Internal'; | ||
import { List } from '../../_Internal'; | ||
declare type _Merge<O extends object, Path extends List<string>, O1 extends object, I extends Iteration = IterationOf<'0'>> = { | ||
declare type _Merge<O extends object, Path extends string[], O1 extends object, I extends Iteration = IterationOf<'0'>> = { | ||
[K in keyof O]: K extends Path[Pos<I>] ? Pos<Next<I>> extends Length<Path> ? OMerge<O[K] & {}, O1> : Compute<_Merge<O[K] & {}, Path, O1, Next<I>>> : O[K]; | ||
@@ -11,0 +11,0 @@ }; |
import { Length } from '../../Tuple/Length'; | ||
import { Compute } from '../../Extras/Compute'; | ||
import { Iteration, IterationOf } from '../../Iteration/IterationOf'; | ||
import { Compute } from '../../Any/Compute'; | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
@@ -8,4 +9,3 @@ import { Next } from '../../Iteration/Next'; | ||
import { Path as PPath } from './_Internal'; | ||
import { List } from '../../_Internal'; | ||
declare type _Omit<O extends object, Path extends List<string>, I extends Iteration = IterationOf<'0'>> = Select<{ | ||
declare type _Omit<O extends object, Path extends string[], I extends Iteration = IterationOf<'0'>> = Select<{ | ||
[K in keyof O]: K extends Path[Pos<I>] ? Pos<Next<I>> extends Length<Path> ? never : Compute<_Omit<O[K] & {}, Path, Next<I>>> : O[K]; | ||
@@ -12,0 +12,0 @@ }, any>; |
import { Length } from '../../Tuple/Length'; | ||
import { Compute } from '../../Extras/Compute'; | ||
import { Iteration, IterationOf } from '../../Iteration/IterationOf'; | ||
import { Compute } from '../../Any/Compute'; | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { Select } from '../Select'; | ||
import { List } from '../../_Internal'; | ||
import { Path as PPath } from './_Internal'; | ||
declare type _Pick<O extends object, Path extends List<string>, I extends Iteration = IterationOf<'0'>> = Select<{ | ||
declare type _Pick<O extends object, Path extends string[], I extends Iteration = IterationOf<'0'>> = Select<{ | ||
[K in keyof O]: K extends Path[Pos<I>] ? Pos<Next<I>> extends Length<Path> ? O[K] : Compute<_Pick<O[K] & {}, Path, Next<I>>> : never; | ||
@@ -11,0 +11,0 @@ }, any>; |
import { Length } from '../../Tuple/Length'; | ||
import { Compute } from '../../Extras/Compute'; | ||
import { Iteration, IterationOf } from '../../Iteration/IterationOf'; | ||
import { Compute } from '../../Any/Compute'; | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
@@ -11,5 +12,4 @@ import { Next } from '../../Iteration/Next'; | ||
import { Path as PPath } from './_Internal'; | ||
import { List } from '../../_Internal'; | ||
import { Prepend } from '../../Tuple/_api'; | ||
declare type _Readonly<O extends object, Path extends List<string>, K extends string, depth extends Depth, I extends Iteration = IterationOf<'0'>> = { | ||
import { Prepend } from '../../Tuple/Prepend'; | ||
declare type _Readonly<O extends object, Path extends string[], K extends string, depth extends Depth, I extends Iteration = IterationOf<'0'>> = { | ||
[P in keyof O]: P extends Path[Pos<I>] ? Pos<Next<I>> extends Length<Path> ? OReadonly<O[P] & {}, K, depth> : Compute<_Readonly<O[P] & {}, Path, K, depth, Next<I>>> : O[P]; | ||
@@ -16,0 +16,0 @@ }; |
import { Length } from '../../Tuple/Length'; | ||
import { Compute } from '../../Extras/Compute'; | ||
import { Iteration, IterationOf } from '../../Iteration/IterationOf'; | ||
import { Compute } from '../../Any/Compute'; | ||
import { IterationOf } from '../../Iteration/IterationOf'; | ||
import { Iteration } from '../../Iteration/Iteration'; | ||
import { Pos } from '../../Iteration/Pos'; | ||
import { Next } from '../../Iteration/Next'; | ||
import { List } from '../../_Internal'; | ||
import { Path as PPath } from './_Internal'; | ||
declare type _Update<O extends object, Path extends List<string>, A, I extends Iteration = IterationOf<'0'>> = { | ||
declare type _Update<O extends object, Path extends string[], A, I extends Iteration = IterationOf<'0'>> = { | ||
[K in keyof O]: K extends Path[Pos<I>] ? Pos<Next<I>> extends Length<Path> ? A : Compute<_Update<O[K] & {}, Path, A, Next<I>>> : O[K]; | ||
@@ -10,0 +10,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Next } from '../Iteration/Next'; | ||
@@ -9,3 +10,3 @@ import { Pos } from '../Iteration/Pos'; | ||
declare type _Path<O, Path extends string[], I extends Iteration = IterationOf<'0'>> = { | ||
0: _Path<UNonNullable<At<Cast<O, object>, Path[Pos<I>]>>, Path, Next<I>>; | ||
0: _Path<UNonNullable<At<O & {}, Path[Pos<I>]>>, Path, Next<I>>; | ||
1: O; | ||
@@ -12,0 +13,0 @@ }[Pos<I> extends Length<Path> ? 1 : 0]; |
import { Merge } from './Merge'; | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Pick } from './Pick'; | ||
@@ -11,3 +9,3 @@ import { Depth } from './_Internal'; | ||
declare type ReadonlyDeep<O> = { | ||
+readonly [K in keyof O]: Extends<UNonNullable<O[K]>, object> extends true ? ReadonlyDeep<O[K]> : O[K]; | ||
+readonly [K in keyof O]: ReadonlyDeep<O[K]>; | ||
}; | ||
@@ -14,0 +12,0 @@ declare type ReadonlyPart<O extends object, depth extends Depth> = { |
@@ -1,6 +0,3 @@ | ||
import { Record } from './Record'; | ||
import { SelectKeys } from './SelectKeys'; | ||
import { Modx } from './_Internal'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Overwrite } from './Overwrite'; | ||
import { Is } from '../Any/Is'; | ||
/** Update with **`A`** the fields of **`O`** that match **`M`** | ||
@@ -10,3 +7,2 @@ * @param O to update | ||
* @param A to update with | ||
* @param modx to set modifiers (?=['!', 'W']) | ||
* @param match to change precision (?=`'default'`) | ||
@@ -16,2 +12,4 @@ * @returns **`object`** | ||
*/ | ||
export declare type Replace<O extends object, M extends any, A extends any, modx extends Modx = ['!', 'W'], match extends Match = 'default'> = Overwrite<O, Record<SelectKeys<O, M, match>, A, modx>>; | ||
export declare type Replace<O extends object, M extends any, A extends any, match extends Match = 'default'> = { | ||
[K in keyof O]: Is<O[K], M, match> extends true ? A : O[K]; | ||
}; |
import { Merge } from './Merge'; | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Pick } from './Pick'; | ||
@@ -11,3 +9,3 @@ import { Depth } from './_Internal'; | ||
declare type RequiredDeep<O> = { | ||
[K in keyof O]-?: Extends<UNonNullable<O[K]>, object> extends true ? RequiredDeep<O[K]> : O[K]; | ||
[K in keyof O]-?: RequiredDeep<O[K]>; | ||
}; | ||
@@ -14,0 +12,0 @@ declare type RequiredPart<O extends object, depth extends Depth> = { |
import { SelectKeys } from './SelectKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Pick } from './Pick'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Extract the fields of **`O`** that match **`M`** | ||
@@ -11,2 +12,2 @@ * @param O to extract from | ||
*/ | ||
export declare type Select<O extends object, M extends any, match extends Match = 'default'> = Pick<O, SelectKeys<O, M, match>>; | ||
export declare type Select<O extends object, M extends any, match extends Match = 'default'> = Pick<O, SelectKeys<O, M, match>> extends infer X ? Cast<X, object> : never; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Prepend } from '../Tuple/Prepend'; | ||
@@ -7,5 +8,5 @@ import { Prev } from '../Iteration/Prev'; | ||
import { Key } from '../Iteration/Key'; | ||
import { List } from '../_Internal'; | ||
declare type PickIfEntry<O extends object, TN extends List, I extends Iteration> = Key<I> extends keyof O ? Prepend<TN, O[Cast<Key<I>, keyof O>]> : TN; | ||
declare type _TupleOf<O extends object, TN extends List, I extends Iteration> = { | ||
import { Min } from '../Number/Min'; | ||
declare type PickIfEntry<O extends object, TN extends any[], I extends Iteration> = Key<I> extends keyof O ? Prepend<TN, O[Cast<Key<I>, keyof O>]> : TN; | ||
declare type _TupleOf<O extends object, TN extends any[], I extends Iteration> = { | ||
0: _TupleOf<O, PickIfEntry<O, TN, I>, Prev<I>>; | ||
@@ -18,6 +19,6 @@ 1: TN; | ||
* @param LastK last index to pick | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type TupleOf<O extends object, LastK extends Nbr> = _TupleOf<O, [], IterationOf<LastK>> extends infer X ? Cast<X, List> : never; | ||
export declare type TupleOf<O extends object, LastK extends Nbr> = _TupleOf<O, [], IterationOf<Min<LastK>>> extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
@@ -1,6 +0,5 @@ | ||
import { NonNullable as UNonNullable } from '../Union/NonNullable'; | ||
import { Extends } from '../Any/Extends'; | ||
import { Pick } from './Pick'; | ||
import { Depth } from './_Internal'; | ||
import { Merge } from './Merge'; | ||
import { Equals } from '../Any/Equals'; | ||
declare type WritableFlat<O> = { | ||
@@ -10,3 +9,3 @@ -readonly [K in keyof O]: O[K]; | ||
declare type WritableDeep<O> = { | ||
-readonly [K in keyof O]: Extends<UNonNullable<O[K]>, object> extends true ? WritableDeep<O[K]> : O[K]; | ||
-readonly [K in keyof O]: WritableDeep<O[K]>; | ||
}; | ||
@@ -24,3 +23,3 @@ declare type WritablePart<O extends object, depth extends Depth> = { | ||
*/ | ||
export declare type Writable<O extends object, K extends string = keyof O, depth extends Depth = 'flat'> = Merge<WritablePart<Pick<O, K>, depth>, O>; | ||
export declare type Writable<O extends object, K extends string = keyof O, depth extends Depth = 'flat'> = Equals<K, keyof O> extends true ? WritablePart<O, depth> : Merge<WritablePart<Pick<O, K>, depth>, O>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { IterationOf, IterationMap } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Pos } from '../Iteration/Pos'; | ||
@@ -8,2 +8,2 @@ /** Transform a **`string`** into a **`number`** | ||
*/ | ||
export declare type NumberOf<N extends string> = N extends keyof IterationMap ? Pos<IterationOf<N>> : number; | ||
export declare type NumberOf<N extends string> = Pos<IterationOf<N>>; |
@@ -25,2 +25,3 @@ export { Append } from './Append'; | ||
export { MergeKeys } from './MergeKeys'; | ||
export { Modify } from './Modify'; | ||
export { NonNullable } from './NonNullable'; | ||
@@ -36,2 +37,3 @@ export { NonNullableKeys } from './NonNullableKeys'; | ||
export { Pick } from './Pick'; | ||
export { Pop } from './Pop'; | ||
export { Prepend } from './Prepend'; | ||
@@ -38,0 +40,0 @@ export { Readonly } from './Readonly'; |
import { Concat } from './Concat'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Add an element **`A`** at the end of **`T`** | ||
* @param T to append to | ||
* @param A to be added to | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Append<T extends List, A extends any> = Concat<T, [A]>; | ||
export declare type Append<T extends any[], A extends any> = Concat<T, [A]> extends infer X ? Cast<X, any[]> : never; |
@@ -0,10 +1,9 @@ | ||
import { Reverse } from './Reverse'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Reverse } from './Reverse'; | ||
import { List } from '../_Internal'; | ||
/** Attach **`T1`** at the end of **`T`** | ||
* @param T to concat with | ||
* @param T1 to be attached | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Concat<T extends List, T1 extends List = []> = Reverse<Reverse<T>, T1> extends infer X ? Cast<X, List> : never; | ||
export declare type Concat<T extends any[], T1 extends any[]> = Reverse<Reverse<T>, T1> extends infer X ? Cast<X, any[]> : never; |
@@ -7,3 +7,2 @@ import { Diff as ODiff } from '../Object/Diff'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Get a **tuple** that is the difference between **`T`** & **`T1`** | ||
@@ -15,5 +14,5 @@ * (**`T`**'s differences have priority over **`T1`**'s if entries overlap) | ||
* @param match to change precision (?=`'default'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Diff<T extends List, T1 extends List, match extends Match = 'default'> = TupleOf<ODiff<T, T1, match>, Length<Longest<T, T1>, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Diff<T extends any[], T1 extends any[], match extends Match = 'default'> = TupleOf<ODiff<T, T1, match>, Length<Longest<T, T1>, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { Tail } from './Tail'; | ||
import { Next } from '../Iteration/Next'; | ||
import { Reverse } from './Reverse'; | ||
import { Cast } from '../Any/Cast'; | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from '../Number/_Internal'; | ||
import { Key } from '../Iteration/Key'; | ||
import { Way } from '../_Internal'; | ||
import { List } from '../_Internal'; | ||
declare type _Drop<T extends List, N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: _Drop<Tail<T>, N, Next<I>>; | ||
import { Pop } from './Pop'; | ||
declare type DropForth<T extends any[], N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: DropForth<Tail<T>, N, Next<I>>; | ||
1: T; | ||
}[N extends Key<I> ? 1 : 0]; | ||
declare type DropBack<T extends any[], N extends Nbr, I extends Iteration = IterationOf<'0'>> = { | ||
0: DropBack<Pop<T>, N, Next<I>>; | ||
1: T; | ||
}[N extends Key<I> ? 1 : 0]; | ||
/** Remove **`N`** entries out of **`T`** | ||
@@ -18,9 +22,9 @@ * @param T to remove from | ||
* @param way to remove from end (?='->') | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Drop<T extends List, N extends Nbr, way extends Way = '->'> = { | ||
'->': _Drop<T, N>; | ||
'<-': Reverse<_Drop<Reverse<T>, N>>; | ||
}[way] extends infer X ? Cast<X, List> : never; | ||
export declare type Drop<T extends any[], N extends Nbr, way extends Way = '->'> = { | ||
'->': DropForth<T, N>; | ||
'<-': DropBack<T, N>; | ||
}[way] extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
@@ -6,3 +6,2 @@ import { Match } from '../Any/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Exclude the entries of **`T1`** out of **`T`** | ||
@@ -13,5 +12,5 @@ * (If `match = 'default'`, no type checks are done) | ||
* @param match to change precision (?=`'default'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Exclude<T extends List, T1 extends List, match extends Match = 'default'> = TupleOf<OExclude<T, T1, match>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Exclude<T extends any[], T1 extends any[], match extends Match = 'default'> = TupleOf<OExclude<T, T1, match>, Length<T, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { ExcludeKeys as OExcludeKeys } from '../Object/ExcludeKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { List } from '../_Internal'; | ||
/** Exclude the keys of **`T1`** out of the keys of **`T`** | ||
@@ -12,2 +11,2 @@ * (If `match = 'default'`, no type checks are done) | ||
*/ | ||
export declare type ExcludeKeys<T extends List, T1 extends List, match extends Match = 'default'> = OExcludeKeys<T, T1, match>; | ||
export declare type ExcludeKeys<T extends any[], T1 extends any[], match extends Match = 'default'> = OExcludeKeys<T, T1, match>; |
@@ -5,3 +5,2 @@ import { KeySet } from './KeySet'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Pick a range of entries (portion) from **`T`** | ||
@@ -11,5 +10,5 @@ * @param T to pick from | ||
* @param To to end with | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Extract<T extends List, From extends Nbr, To extends Nbr> = Pick<T, KeySet<From, To>> extends infer X ? Cast<X, List> : never; | ||
export declare type Extract<T extends any[], From extends Nbr, To extends Nbr> = Pick<T, KeySet<From, To>> extends infer X ? Cast<X, any[]> : never; |
@@ -6,3 +6,2 @@ import { Filter as OFilter } from '../Object/Filter'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Filter out of **`T`** the entries that match **`M`** | ||
@@ -12,5 +11,5 @@ * @param T to remove from | ||
* @param match to change precision (?=`'default'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Filter<T extends List, M extends any, match extends Match = 'default'> = TupleOf<OFilter<T, M, match>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Filter<T extends any[], M extends any, match extends Match = 'default'> = TupleOf<OFilter<T, M, match>, Length<T, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { FilterKeys as OFilterKeys } from '../Object/FilterKeys'; | ||
import { Match } from '../Any/_Internal'; | ||
import { List } from '../_Internal'; | ||
/** Filter out the keys of **`T`** which entries match **`M`** | ||
@@ -11,2 +10,2 @@ * @param T to remove from | ||
*/ | ||
export declare type FilterKeys<T extends List, M extends any, match extends Match = 'default'> = OFilterKeys<T, M, match>; | ||
export declare type FilterKeys<T extends any[], M extends any, match extends Match = 'default'> = OFilterKeys<T, M, match>; |
@@ -5,17 +5,15 @@ import { Nbr } from '../Number/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Length } from './Length'; | ||
import { Prepend } from './Prepend'; | ||
import { Reverse } from './Reverse'; | ||
import { List } from '../_Internal'; | ||
declare type _Group<T extends List, N extends Nbr, TN extends List = []> = { | ||
declare type _Group<T extends any[], N extends Nbr, TN extends any[] = []> = { | ||
0: _Group<Drop<T, N>, N, Prepend<TN, Take<T, N>>>; | ||
1: Reverse<TN>; | ||
}[Length<T> extends 0 ? 1 : 0]; | ||
}[T extends [] ? 1 : 0]; | ||
/** Split **`T`** into sub-**tuple**s every **`N`** | ||
* @param T to group | ||
* @param N to split at | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Group<T extends List, N extends Nbr> = _Group<T, N> extends infer X ? Cast<X, List> : never; | ||
export declare type Group<T extends any[], N extends Nbr> = _Group<T, N> extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
import { Match } from '../Any/_Internal'; | ||
import { Has as OHas } from '../Object/Has'; | ||
import { List } from '../_Internal'; | ||
/** Check whether **`T`** has a entry of key **`K`** that matches **`M`** | ||
@@ -12,2 +11,2 @@ * @param T to be inspected | ||
*/ | ||
export declare type Has<T extends List, K extends string, M extends any = any, match extends Match = 'default'> = OHas<T, K, M, match>; | ||
export declare type Has<T extends any[], K extends string, M extends any = any, match extends Match = 'default'> = OHas<T, K, M, match>; |
import { HasPath as OHasPath } from '../Object/HasPath'; | ||
import { Match } from '../Any/_Internal'; | ||
import { List } from '../_Internal'; | ||
/** Check whether **`T`** has nested entries that match **`M`** | ||
@@ -12,2 +11,2 @@ * @param T to be inspected | ||
*/ | ||
export declare type HasPath<T extends List, Path extends string[], M extends any = any, match extends Match = 'default'> = OHasPath<T, Path, M, match>; | ||
export declare type HasPath<T extends any[], Path extends string[], M extends any = any, match extends Match = 'default'> = OHasPath<T, Path, M, match>; |
@@ -1,2 +0,1 @@ | ||
import { List } from '../_Internal'; | ||
/** Get the first entry of **`T`** | ||
@@ -7,2 +6,2 @@ * @param T to extract from | ||
*/ | ||
export declare type Head<T extends List> = T extends [any, ...List] ? T[0] : never; | ||
export declare type Head<T extends any[]> = T extends [any, ...any[]] ? T[0] : never; |
import { Match } from '../Any/_Internal'; | ||
import { Includes as OIncludes } from '../Object/Includes'; | ||
import { List } from '../_Internal'; | ||
/** Check whether **`T`** has entries that match **`M`** | ||
@@ -11,2 +10,2 @@ * @param T to be inspected | ||
*/ | ||
export declare type Includes<T extends List, M extends any, match extends Match = 'default'> = OIncludes<T, M, match>; | ||
export declare type Includes<T extends any[], M extends any, match extends Match = 'default'> = OIncludes<T, M, match>; |
@@ -7,3 +7,2 @@ import { Intersect as OIntersect } from '../Object/Intersect'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Get the intersecting entries of **`T`** & **`T1`** | ||
@@ -13,5 +12,5 @@ * (If `match = 'default'`, no type checks are done) | ||
* @param T1 to check similarities against | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Intersect<T extends List, T1 extends List, match extends Match = 'default'> = TupleOf<OIntersect<T, T1, match>, Length<Longest<T, T1>, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Intersect<T extends any[], T1 extends any[], match extends Match = 'default'> = TupleOf<OIntersect<T, T1, match>, Length<Longest<T, T1>, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { Match } from '../Any/_Internal'; | ||
import { IntersectKeys as OIntersectKeys } from '../Object/IntersectKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the intersecting entries of **`T`** & **`T1`** | ||
@@ -11,2 +10,2 @@ * (If `match = 'default'`, no type checks are done) | ||
*/ | ||
export declare type IntersectKeys<T extends List, T1 extends List, match extends Match = 'default'> = OIntersectKeys<T, T1, match>; | ||
export declare type IntersectKeys<T extends any[], T1 extends any[], match extends Match = 'default'> = OIntersectKeys<T, T1, match>; |
import { Exclude } from '../Union/Exclude'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Get the own keys of a **tuple** | ||
@@ -9,2 +7,2 @@ * @param T | ||
*/ | ||
export declare type Keys<T extends List> = Exclude<keyof T, keyof List> extends infer X ? Cast<X, keyof T> : never; | ||
export declare type Keys<T extends any[]> = Exclude<keyof T, keyof any[]>; |
import { Tail } from './Tail'; | ||
import { Length } from './Length'; | ||
import { List } from '../_Internal'; | ||
import { Limit } from './_Internal'; | ||
/** Get the last entry of **`T`** | ||
* @param T to extract from | ||
* @param limit to count (or not) optionals (?=`'reg'`) | ||
* @returns **`any`** | ||
* @example | ||
*/ | ||
export declare type Last<T extends List, limit extends Limit = 'reg'> = T[Length<Tail<T>, 'n', limit>]; | ||
export declare type Last<T extends any[]> = T[Length<Tail<T>, 'n'>]; |
@@ -1,27 +0,12 @@ | ||
import { Min } from '../Number/Min'; | ||
import { Max } from '../Number/Max'; | ||
import { StringOf } from '../Number/StringOf'; | ||
import { Format } from '../Iteration/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Limit } from './_Internal'; | ||
import { List } from '../_Internal'; | ||
declare type Reg<N extends number, fmt extends Format> = { | ||
's': StringOf<N>; | ||
'n': N; | ||
}[fmt]; | ||
/** Get the length of **`T`** | ||
* @param T to get length | ||
* @param fmt output (?=`'n'`) | ||
* @param limit to count (or not) optionals (?=`'reg'`) | ||
* @returns **`string`** or **`number`** | ||
* @example | ||
*/ | ||
export declare type Length<T extends List, fmt extends Format = 'n', limit extends Limit = 'reg'> = { | ||
'min': Min<StringOf<T['length']>, fmt>; | ||
'max': Max<StringOf<T['length']>, fmt>; | ||
'reg': Reg<T['length'], fmt>; | ||
}[limit] extends infer X ? Cast<X, { | ||
s: string; | ||
n: number; | ||
}[fmt]> : never; | ||
export {}; | ||
export declare type Length<T extends any[], fmt extends Format = 'n'> = { | ||
's': StringOf<T['length']>; | ||
'n': T['length']; | ||
}[fmt]; |
import { Exclude } from '../Union/Exclude'; | ||
import { List } from '../_Internal'; | ||
/** Get the longest **tuple** of **`T`** & **`T2`** | ||
@@ -10,2 +9,2 @@ * (**`T`** has priority if both lengths are equal) | ||
*/ | ||
export declare type Longest<T extends List, T1 extends List> = Exclude<keyof T1, keyof T> extends never ? T : T1; | ||
export declare type Longest<T extends any[], T1 extends any[]> = Exclude<keyof T1, keyof T> extends never ? T : T1; |
import { Longest } from './Longest'; | ||
import { List } from '../_Internal'; | ||
import { Length } from './Length'; | ||
import { Concat } from './Concat'; | ||
import { Drop } from './Drop'; | ||
/** Complete the entries of **`T`** with the ones of **`T1`** | ||
* @param T to complete | ||
* @param T1 to copy from | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Merge<T extends List, T1 extends List> = T1 extends Longest<T, T1> ? { | ||
[K in keyof T1]: K extends keyof T ? T[K] : T1[K]; | ||
} : T; | ||
export declare type Merge<T extends any[], T1 extends any[]> = T1 extends Longest<T, T1> ? Concat<T, Drop<T1, Length<T, 's'>>> : T; |
import { MergeKeys as OMergeKeys } from '../Object/MergeKeys'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T` & `T1`** | ||
@@ -10,2 +8,2 @@ * @param T | ||
*/ | ||
export declare type MergeKeys<T extends List, T1 extends List> = OMergeKeys<T, T1> extends infer X ? Cast<X, keyof (T & T1)> : never; | ||
export declare type MergeKeys<T extends any[], T1 extends any[]> = OMergeKeys<T, T1>; |
@@ -6,4 +6,4 @@ import { Depth } from '../Object/_Internal'; | ||
import { Equals } from '../Any/Equals'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Overwrite } from './Overwrite'; | ||
/** Make some entries of **`T`** not nullable (deeply or not) | ||
@@ -13,5 +13,5 @@ * @param T to make non nullable | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type NonNullable<T extends List, K extends string = keyof T, depth extends Depth = 'flat'> = Equals<K, keyof T> extends true ? Cast<ONonNullable<T, K, depth>, List> : TupleOf<ONonNullable<T, K, depth>, Length<T, 's', 'max'>>; | ||
export declare type NonNullable<T extends any[], K extends string = keyof T, depth extends Depth = 'flat'> = Equals<K, keyof T> extends true ? Cast<ONonNullable<T, K, depth>, any[]> : Overwrite<T, TupleOf<ONonNullable<T, K, depth>, Length<T, 's'>>>; |
import { NonNullableKeys as ONonNullableKeys } from '../Object/NonNullableKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T`** that are non-nullable | ||
@@ -8,2 +7,2 @@ * @param T | ||
*/ | ||
export declare type NonNullableKeys<T extends List> = ONonNullableKeys<T>; | ||
export declare type NonNullableKeys<T extends any[]> = ONonNullableKeys<T>; |
@@ -6,4 +6,4 @@ import { Depth } from '../Object/_Internal'; | ||
import { Length } from './Length'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Overwrite } from './Overwrite'; | ||
/** Make some entries of **`T`** nullable (deeply or not) | ||
@@ -13,5 +13,5 @@ * @param T to make nullable | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Nullable<T extends List, K extends string = keyof T, depth extends Depth = 'flat'> = Equals<K, keyof T> extends true ? Cast<ONullable<T, K, depth>, List> : TupleOf<ONullable<T, K, depth>, Length<T, 's', 'max'>>; | ||
export declare type Nullable<T extends any[], K extends string = keyof T, depth extends Depth = 'flat'> = Equals<K, keyof T> extends true ? Cast<ONullable<T, K, depth>, any[]> : Overwrite<T, TupleOf<ONullable<T, K, depth>, Length<T, 's'>>>; |
import { NullableKeys as ONullableKeys } from '../Object/NullableKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T`** that are nullable | ||
@@ -8,2 +7,2 @@ * @param T | ||
*/ | ||
export declare type NullableKeys<T extends List> = ONullableKeys<T>; | ||
export declare type NullableKeys<T extends any[]> = ONullableKeys<T>; |
import { Omit } from '../Object/Omit'; | ||
import { List } from '../_Internal'; | ||
/** Transform a **tuple** into an **`object`** | ||
@@ -8,2 +7,2 @@ * @param T to transform | ||
*/ | ||
export declare type ObjectOf<T extends List> = Omit<T, keyof List>; | ||
export declare type ObjectOf<T extends any[]> = Omit<T, keyof any[]>; |
@@ -5,9 +5,8 @@ import { Omit as OOmit } from '../Object/Omit'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Remove out of **`T`** the entries of key **`K`** | ||
* @param T to remove from | ||
* @param K to chose entries | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Omit<T extends List, K extends string> = TupleOf<OOmit<T, K>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Omit<T extends any[], K extends string> = TupleOf<OOmit<T, K>, Length<T, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { Optional as OOptional } from '../Object/Optional'; | ||
import { Depth } from '../Object/_Internal'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
@@ -8,5 +7,5 @@ /** Make **`T`** optional (deeply or not) | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Optional<T extends List, depth extends Depth = 'flat'> = OOptional<T, keyof T, depth> extends infer X ? Cast<X, List> : never; | ||
export declare type Optional<T extends any[], depth extends Depth = 'flat'> = Cast<OOptional<T, keyof T, depth>, any[]>; |
import { OptionalKeys as OOptionalKeys } from '../Object/OptionalKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T`** that are optional | ||
@@ -8,2 +7,2 @@ * @param T | ||
*/ | ||
export declare type OptionalKeys<T extends List> = OOptionalKeys<T>; | ||
export declare type OptionalKeys<T extends any[]> = OOptionalKeys<T>; |
import { Path as OPath } from '../Object/Path'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Check whether **`T`** has nested properties that match **`M`** | ||
/** Get in **`T`** the type of nested properties | ||
* @param T to be inspected | ||
* @param Path to be followed | ||
* @returns **`true`** or **`false`** | ||
* @returns **`any`** | ||
* @example | ||
*/ | ||
export declare type Path<T extends List, Path extends string[]> = OPath<T, Path> extends infer X ? Cast<X, List> : never; | ||
export declare type Path<T extends any[], Path extends string[]> = OPath<T, Path>; |
@@ -5,9 +5,8 @@ import { Pick as OPick } from '../Object/Pick'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Extract out of **`T`** the entries of key **`K`** | ||
* @param T to extract from | ||
* @param K to chose entries | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Pick<T extends List, K extends string> = TupleOf<OPick<T, K>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Pick<T extends any[], K extends string> = TupleOf<OPick<T, K>, Length<T, 's'>> extends infer X ? Cast<X, any[]> : never; |
@@ -5,5 +5,4 @@ import { Omit } from './Omit'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Prev } from '../Iteration/Prev'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Prev } from '../Iteration/Prev'; | ||
import { List } from '../_Internal'; | ||
export declare type Pop<T extends List> = Omit<T, Key<Prev<IterationOf<Length<T, 's', 'max'>>>>> extends infer X ? Cast<X, List> : never; | ||
export declare type Pop<T extends any[]> = Omit<T, Key<Prev<IterationOf<Length<T, 's'>>>>> extends infer X ? Cast<X, any[]> : never; |
@@ -1,8 +0,7 @@ | ||
import { List } from '../_Internal'; | ||
/** Add an element **`A`** at the beginning of **`T`** | ||
* @param T to append to | ||
* @param A to be added to | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Prepend<T extends List, A extends any> = ((head: A, ...args: T) => any) extends ((...args: infer U) => any) ? U : T; | ||
export declare type Prepend<T extends any[], A extends any> = ((head: A, ...args: T) => any) extends ((...args: infer U) => any) ? U : T; |
import { Depth } from '../Object/_Internal'; | ||
import { Readonly as OReadonly } from '../Object/Readonly'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
/** Make **`T`** readonly (deeply or not) | ||
* @param T to make readonly | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Readonly<T extends List, depth extends Depth = 'flat'> = OReadonly<T, keyof T, depth> extends infer X ? Cast<X, List> : never; | ||
export declare type Readonly<T extends any[], depth extends Depth = 'flat'> = OReadonly<T, keyof T, depth>; |
import { ReadonlyKeys as OReadonlyKeys } from '../Object/ReadonlyKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T`** that are readonly | ||
@@ -8,2 +7,2 @@ * @param T | ||
*/ | ||
export declare type ReadonlyKeys<T extends List> = OReadonlyKeys<T>; | ||
export declare type ReadonlyKeys<T extends any[]> = OReadonlyKeys<T>; |
@@ -5,3 +5,2 @@ import { Nbr } from '../Number/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Remove out of **`T`** a range of entries | ||
@@ -11,5 +10,5 @@ * @param T to remove from | ||
* @param To to end with | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Remove<T extends List, From extends Nbr, To extends Nbr> = Omit<T, KeySet<From, To>> extends infer X ? Cast<X, List> : never; | ||
export declare type Remove<T extends any[], From extends Nbr, To extends Nbr> = Omit<T, KeySet<From, To>> extends infer X ? Cast<X, any[]> : never; |
import { Next } from '../Iteration/Next'; | ||
import { Prepend } from './Prepend'; | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Nbr } from '../Number/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { Key } from '../Iteration/Key'; | ||
import { List } from '../_Internal'; | ||
declare type _Repeat<N extends Nbr, A, T extends List = [], I extends Iteration = IterationOf<'0'>> = { | ||
declare type _Repeat<N extends Nbr, A, T extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _Repeat<N, A, Prepend<T, A>, Next<I>>; | ||
@@ -16,6 +16,6 @@ 1: T; | ||
* @param T to be filled (?=[]) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Repeat<A extends any, N extends Nbr, T extends List = []> = _Repeat<N, A, T> extends infer X ? Cast<X, List> : never; | ||
export declare type Repeat<A extends any, N extends Nbr, T extends any[] = []> = _Repeat<N, A, T> extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
import { Replace as OReplace } from '../Object/Replace'; | ||
import { Modx } from '../Object/_Internal'; | ||
import { TupleOf } from '../Object/TupleOf'; | ||
import { Length } from './Length'; | ||
import { Match } from '../Any/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Update with **`A`** the entries of **`T`** that match **`M`** | ||
* @param T to update | ||
* @param M to select entries | ||
* @param O to update | ||
* @param M to select fields | ||
* @param A to update with | ||
* @param modx to set modifiers (?=`['!', 'W']`) | ||
* @returns **`List`** | ||
* @param match to change precision (?=`'default'`) | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Replace<T extends List, M extends any, A extends any, modx extends Modx = ['!', 'W']> = TupleOf<OReplace<T, M, A, modx>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Replace<T extends any[], M extends any, A extends any, match extends Match = 'default'> = Cast<OReplace<T, M, A, match>, any[]>; |
import { Depth } from '../Object/_Internal'; | ||
import { Required as ORequired } from '../Object/Required'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
@@ -8,5 +7,5 @@ /** Make **`T`** required (deeply or not) | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Required<T extends List, depth extends Depth = 'flat'> = ORequired<T, keyof T, depth> extends infer X ? Cast<X, List> : never; | ||
export declare type Required<T extends any[], depth extends Depth = 'flat'> = Cast<ORequired<T, keyof T, depth>, any[]>; |
@@ -5,15 +5,15 @@ import { Prepend } from './Prepend'; | ||
import { Length } from './Length'; | ||
import { IterationOf, Iteration } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
export declare type _Reverse<T extends List, TO extends List = [], I extends Iteration = IterationOf<'0'>> = { | ||
export declare type _Reverse<T extends any[], TO extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _Reverse<T, Prepend<TO, T[Pos<I>]>, Next<I>>; | ||
1: TO; | ||
}[Pos<I> extends Length<T, 'n', 'max'> ? 1 : 0]; | ||
}[Pos<I> extends Length<T> ? 1 : 0]; | ||
/** Turn a **tuple** the other way around | ||
* @param T to reverse | ||
* @param TO to append to (?=[]) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Reverse<T extends List, TO extends List = []> = _Reverse<T, TO> extends infer X ? Cast<X, List> : never; | ||
export declare type Reverse<T extends any[], TO extends any[] = []> = _Reverse<T, TO> extends infer X ? Cast<X, any[]> : never; |
@@ -6,3 +6,2 @@ import { Match } from '../Any/_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
/** Extract the entries of **`T`** that match **`M`** | ||
@@ -12,5 +11,5 @@ * @param T to extract from | ||
* @param match to change precision (?=`'default'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Select<T extends List, M extends any, match extends Match = 'default'> = TupleOf<OSelect<T, M, match>, Length<T, 's', 'max'>> extends infer X ? Cast<X, List> : never; | ||
export declare type Select<T extends any[], M extends any, match extends Match = 'default'> = TupleOf<OSelect<T, M, match>, Length<T, 's'>> extends infer X ? Cast<X, any[]> : never; |
import { Match } from '../Any/_Internal'; | ||
import { SelectKeys as OSelectKeys } from '../Object/SelectKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`T`** which entries match **`M`** | ||
@@ -11,2 +10,2 @@ * @param T to extract from | ||
*/ | ||
export declare type SelectKeys<T extends List, M extends any, match extends Match = 'default'> = OSelectKeys<T, M, match>; | ||
export declare type SelectKeys<T extends any[], M extends any, match extends Match = 'default'> = OSelectKeys<T, M, match>; |
@@ -1,7 +0,6 @@ | ||
import { List } from '../_Internal'; | ||
/** Remove the first item out of a **tuple** | ||
* @param T | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Tail<T extends List> = ((...t: T) => any) extends ((_: any, ...tail: infer TTail) => any) ? TTail : never; | ||
export declare type Tail<T extends any[]> = ((...t: T) => any) extends ((head: any, ...tail: infer TTail) => any) ? TTail : never; |
import { Nbr } from '../Number/_Internal'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Pos } from '../Iteration/Pos'; | ||
@@ -10,4 +11,3 @@ import { Next } from '../Iteration/Next'; | ||
import { Way } from '../_Internal'; | ||
import { List } from '../_Internal'; | ||
declare type _Take<T extends List, N extends Nbr, TN extends List = [], I extends Iteration = IterationOf<'0'>> = { | ||
declare type _Take<T extends any[], N extends Nbr, TN extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _Take<T, N, Prepend<TN, T[Pos<I>]>, Next<I>>; | ||
@@ -20,9 +20,9 @@ 1: TN; | ||
* @param way to extract from end (?='->') | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Take<T extends List, N extends Nbr, way extends Way = '->'> = { | ||
export declare type Take<T extends any[], N extends Nbr, way extends Way = '->'> = { | ||
'->': Reverse<_Take<T, N>>; | ||
'<-': _Take<Reverse<T>, N>; | ||
}[way] extends infer X ? Cast<X, List> : never; | ||
}[way] extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
import { List } from '../_Internal'; | ||
/** Transform a **tuple** into an **union** | ||
@@ -7,2 +6,2 @@ * @param T to transform | ||
*/ | ||
export declare type UnionOf<T extends List> = T[number]; | ||
export declare type UnionOf<T extends any[]> = T[number]; |
@@ -1,2 +0,1 @@ | ||
import { Tail } from './Tail'; | ||
import { Concat } from './Concat'; | ||
@@ -6,14 +5,17 @@ import { Append } from './Append'; | ||
import { Length } from './Length'; | ||
import { List } from '../_Internal'; | ||
declare type _UnNest<T extends List, TN extends List = []> = { | ||
0: _UnNest<Tail<T>, Concat<TN, T[0]>>; | ||
1: _UnNest<Tail<T>, Append<TN, T[0]>>; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Next } from '../Iteration/Next'; | ||
import { Pos } from '../Iteration/Pos'; | ||
declare type _UnNest<T extends any[], TN extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _UnNest<T, Concat<TN, T[Pos<I>]>, Next<I>>; | ||
1: _UnNest<T, Append<TN, T[Pos<I>]>, Next<I>>; | ||
2: TN; | ||
}[0 extends Length<T> ? 2 : List extends T[0] ? 0 : 1]; | ||
}[Pos<I> extends Length<T> ? 2 : T[Pos<I>] extends any[] ? 0 : 1]; | ||
/** Remove a dimension of **`T`** | ||
* @param T to un-nest | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type UnNest<T extends List> = _UnNest<T> extends infer X ? Cast<X, List> : never; | ||
export declare type UnNest<T extends any[]> = _UnNest<T> extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
import { Depth } from '../Object/_Internal'; | ||
import { Writable as OWritable } from '../Object/Writable'; | ||
import { List } from '../_Internal'; | ||
import { Cast } from '../Any/Cast'; | ||
@@ -8,5 +7,5 @@ /** Make **`T`** writable (deeply or not) | ||
* @param depth to do it deeply (?=`'flat'`) | ||
* @returns **`List`** | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Writable<T extends List, depth extends Depth = 'flat'> = OWritable<T, keyof T, depth> extends infer X ? Cast<X, List> : never; | ||
export declare type Writable<T extends any[], depth extends Depth = 'flat'> = Cast<OWritable<T, keyof T, depth>, any[]>; |
import { WritableKeys as OWritableKeys } from '../Object/WritableKeys'; | ||
import { List } from '../_Internal'; | ||
/** Get the keys of **`O`** that are writable | ||
@@ -8,2 +7,2 @@ * @param O | ||
*/ | ||
export declare type WritableKeys<T extends List> = OWritableKeys<T>; | ||
export declare type WritableKeys<T extends any[]> = OWritableKeys<T>; |
@@ -1,2 +0,3 @@ | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Prepend } from './Prepend'; | ||
@@ -8,14 +9,13 @@ import { Next } from '../Iteration/Next'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
declare type _Zip<T extends List, T1 extends List, TN extends List = [], I extends Iteration = IterationOf<'0'>> = { | ||
declare type _Zip<T extends any[], T1 extends any[], TN extends any[] = [], I extends Iteration = IterationOf<'0'>> = { | ||
0: _Zip<T, T1, Prepend<TN, [T[Pos<I>], T1[Pos<I>]]>, Next<I>>; | ||
1: Reverse<TN>; | ||
}[Pos<I> extends Length<T> ? 1 : 0]; | ||
/** Pair up the entries of **`T`** & **`T1`** | ||
/** Pair up the entries of **`T`** with **`T1`** | ||
* @param T to pair up | ||
* @param T1 to pair up | ||
* @returns **`List`** | ||
* @param T1 to pair up with | ||
* @returns **`any[]`** | ||
* @example | ||
*/ | ||
export declare type Zip<T extends List, T1 extends List> = _Zip<T, T1> extends infer X ? Cast<X, List> : never; | ||
export declare type Zip<T extends any[], T1 extends any[]> = _Zip<T, T1> extends infer X ? Cast<X, any[]> : never; | ||
export {}; |
import { Length } from './Length'; | ||
import { Pos } from '../Iteration/Pos'; | ||
import { Next } from '../Iteration/Next'; | ||
import { Iteration, IterationOf } from '../Iteration/IterationOf'; | ||
import { IterationOf } from '../Iteration/IterationOf'; | ||
import { Iteration } from '../Iteration/Iteration'; | ||
import { Cast } from '../Any/Cast'; | ||
import { List } from '../_Internal'; | ||
import { Merge } from '../Object/Merge'; | ||
import { Record } from '../Object/Record'; | ||
declare type _ZipObj<TProp extends string[], TField extends List, O extends object = {}, I extends Iteration = IterationOf<'0'>> = { | ||
declare type _ZipObj<TProp extends string[], TField extends any[], O extends object = {}, I extends Iteration = IterationOf<'0'>> = { | ||
0: _ZipObj<TProp, TField, Merge<O, Record<TProp[Pos<I>], TField[Pos<I>]>>, Next<I>>; | ||
@@ -19,3 +19,3 @@ 1: O; | ||
*/ | ||
export declare type ZipObj<TKeys extends string[], TFields extends List> = _ZipObj<TKeys, TFields> extends infer X ? Cast<X, object> : never; | ||
export declare type ZipObj<TKeys extends string[], TFields extends any[]> = _ZipObj<TKeys, TFields> extends infer X ? Cast<X, object> : never; | ||
export {}; |
export { Diff } from './Diff'; | ||
export { Exclude } from './Exclude'; | ||
export { Filter } from './Filter'; | ||
export { Has } from './Has'; | ||
export { Intersect } from './Intersect'; | ||
export { IntersectOf } from './IntersectOf'; | ||
export { Last } from './Last'; | ||
export { NonNullable } from './NonNullable'; | ||
export { Nullable } from './Nullable'; | ||
export { Pop } from './Pop'; | ||
export { Replace } from './Replace'; | ||
export { Select } from './Select'; | ||
export { TupleOf } from './TupleOf'; |
@@ -8,2 +8,2 @@ import { Exclude } from './Exclude'; | ||
*/ | ||
export declare type Diff<U1, U2> = Exclude<U1, U2> | Exclude<U2, U1>; | ||
export declare type Diff<U1 extends any, U2 extends any> = Exclude<U1, U2> | Exclude<U2, U1>; |
@@ -1,7 +0,7 @@ | ||
/** Exclude **`A`** out of **`U`** | ||
/** Remove **`M`** out of **`U`** | ||
* @param U to remove from | ||
* @param A to remove out | ||
* @param M to remove out | ||
* @returns **union** | ||
* @example | ||
*/ | ||
export declare type Exclude<U extends any, A extends any> = U extends A ? never : U; | ||
export declare type Exclude<U extends any, M extends any> = U extends M ? never : U; |
@@ -1,10 +0,9 @@ | ||
import { Equals } from '../Any/Equals'; | ||
import { Intersect } from './Intersect'; | ||
/** Check whether **`U`** contains **`A`** or not | ||
* (Note that **`U`** & **`A`** can be swapped) | ||
* (Note: **`U`** & **`A`** can be interchanged) | ||
* @param U to be inspected | ||
* @param A to check existence | ||
* @param A to check within | ||
* @returns **`true`** or **`false`** | ||
* @example | ||
*/ | ||
export declare type Has<U extends any, A extends any> = Equals<Intersect<U, A>, never> extends true ? false : true; | ||
export declare type Has<U extends any, A extends any> = [Intersect<U, A>] extends [never] ? false : true; |
@@ -7,2 +7,2 @@ /** Get the intersection of **`U1`** & **`U2`** | ||
*/ | ||
export declare type Intersect<U1, U2> = U1 & U2 | U2 & U1; | ||
export declare type Intersect<U1 extends any, U2 extends any> = U1 & U2 | U2 & U1; |
@@ -1,7 +0,7 @@ | ||
/** Extract the part of **`U`** that match **`A`** | ||
/** Extract the part of **`U`** that matches **`A`** | ||
* @param U to extract from | ||
* @param A to select with | ||
* @param M to select with | ||
* @returns **union** | ||
* @example | ||
*/ | ||
export declare type Select<U extends any, A extends any> = U extends A ? U : never; | ||
export declare type Select<U extends any, M extends any> = U extends M ? U : never; |
{ | ||
"name": "ts-toolbelt", | ||
"version": "0.0.16", | ||
"license": "AGPL-3.0-only", | ||
"version": "1.0.0", | ||
"license": "Apache-2.0", | ||
"author": "Pierre-Antoine Mills", | ||
@@ -21,4 +21,7 @@ "description": "👷 Higher type safety for TypeScript", | ||
"scripts": { | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"setup:dev": "npm install --only=dev" | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build:docs": "typedoc --out docs ./src/ --theme ../eledoc/bin/default/", | ||
"setup:dev": "npm install --only=dev", | ||
"git:push": "git add docs/ && git commit -am 'release' && git push origin master", | ||
"prepublish": "rm -fr out && npm run build:types && npm run build:docs && npm run git:push" | ||
}, | ||
@@ -25,0 +28,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
100
0
108543
199
2351