@kakasoo/proto-typescript
Advanced tools
Comparing version 1.7.0 to 1.7.1
import { At, Concat, Join } from '../types'; | ||
import { ReadonlyOrNot } from '../types/primitive.type'; | ||
export declare const ArrayPrototype: { | ||
push<Conatiner extends any[] | readonly any[], Items extends any[] | readonly any[]>(container: Conatiner, ...items: Items): [...Conatiner, ...Items]; | ||
push<Conatiner extends ReadonlyOrNot<any[]>, Items extends ReadonlyOrNot<any[]>>(container: Conatiner, ...items: Items): [...Conatiner, ...Items]; | ||
/** | ||
@@ -8,3 +9,3 @@ * @inheritdoc | ||
*/ | ||
at<Container extends any[] | readonly any[], Index extends number>(container: Container, index: Index): At<Container, Index>; | ||
at<Container extends ReadonlyOrNot<any[]>, Index extends number>(container: Container, index: Index): At<Container, Index>; | ||
/** | ||
@@ -21,4 +22,4 @@ * type-safe join. | ||
*/ | ||
join<Container_1 extends readonly (string | number | boolean)[] | (string | number | boolean)[], Separator extends string = ",">(container: Container_1, separator?: Separator): Join<Container_1, Separator>; | ||
join<Container_1 extends ReadonlyOrNot<(string | number | bigint | boolean | null | undefined)[]>, Separator extends string = ",">(container: Container_1, separator?: Separator): Join<Container_1, Separator>; | ||
}; | ||
//# sourceMappingURL=array.prototype.d.ts.map |
@@ -6,3 +6,4 @@ import { toPrimitive } from './interfaces/to-primitive.interface'; | ||
import { MethodsFrom } from './types'; | ||
export declare class TypedArray<T extends any[] | readonly any[]> implements Pick<MethodsFrom<Array<any>>, 'join' | 'at' | 'push'>, toPrimitive<[...T]> { | ||
import { ReadonlyOrNot } from './types/primitive.type'; | ||
export declare class TypedArray<T extends ReadonlyOrNot<any[]>> implements Pick<MethodsFrom<Array<any>>, 'join' | 'at' | 'push'>, toPrimitive<[...T]> { | ||
private readonly data; | ||
@@ -22,3 +23,3 @@ constructor(data: T); | ||
*/ | ||
push<Items extends any[] | readonly any[]>(...items: Items): TypedArray<ReturnType<typeof ArrayPrototype.push<T, Items>>>; | ||
push<Items extends ReadonlyOrNot<any[]>>(...items: Items): TypedArray<ReturnType<typeof ArrayPrototype.push<T, Items>>>; | ||
/** | ||
@@ -25,0 +26,0 @@ * @inheritDoc |
import { Add, Divide, Multiply, NToNumber, Remainder, Sub } from './number.type'; | ||
import { Equal, Merge } from './object.type'; | ||
export type ElementOf<Tuple extends readonly any[] | any[]> = [...Tuple] extends (infer E)[] ? E : never; | ||
export type Length<T extends any[] | readonly any[]> = T['length']; | ||
export type ArrayValues<T extends any[]> = T[number]; | ||
import { Primitive, ReadonlyOrNot } from './primitive.type'; | ||
export type ElementOf<Tuple extends ReadonlyOrNot<any[]>> = [...Tuple] extends (infer E)[] ? E : never; | ||
export type Length<T extends ReadonlyOrNot<any[]>> = T['length']; | ||
export type ArrayValues<T extends ReadonlyOrNot<any[]>> = T[number]; | ||
/** | ||
@@ -12,5 +13,5 @@ * 현재 튜플 형태에 새로운 타입 하나를 추가하는 타입 | ||
*/ | ||
export type Push<T extends any[] | readonly any[], V extends any> = [...T, V]; | ||
export type Concat<T extends any[] | readonly any[], P extends any[] | readonly any[]> = [...T, ...P]; | ||
export type NTuple<N extends number, T extends any[] = []> = T['length'] extends N ? T : NTuple<N, Push<T, any>>; | ||
export type Push<T extends ReadonlyOrNot<any[]>, V extends any> = [...T, V]; | ||
export type Concat<T extends ReadonlyOrNot<any[]>, P extends ReadonlyOrNot<any[]>> = [...T, ...P]; | ||
export type NTuple<N extends number, T extends ReadonlyOrNot<any[]> = []> = T['length'] extends N ? T : NTuple<N, Push<T, any>>; | ||
/** | ||
@@ -27,15 +28,12 @@ * N1 * N2 크기의 NTuple을 반환하는 타입으로, 최적화를 위해 N1, N2 숫자를 비교하는 과정이 포함된 타입 | ||
*/ | ||
export type Slice<T extends any[], A extends any, B extends any, CONDITION extends boolean = false> = T extends [ | ||
infer X, | ||
...infer Rest | ||
] ? CONDITION extends true ? X extends B ? [X, ...Slice<Rest, A, B, false>] : [X, ...Slice<Rest, A, B, true>] : X extends A ? X extends B ? [X, ...Slice<Rest, A, B, false>] : [X, ...Slice<Rest, A, B, true>] : Slice<Rest, A, B, false> : CONDITION extends true ? never : []; | ||
export type Take<T extends any[], P extends number, R extends any[] = []> = Length<R> extends P ? R : T extends [infer F, ...infer Rest] ? Take<Rest, P, Push<R, F>> : R; | ||
export type TupleIncludes<T extends readonly any[], U> = T extends [infer P, ...infer R] ? Equal<U, P> extends true ? true : TupleIncludes<R, U> : false; | ||
export type Slice<T extends ReadonlyOrNot<any[]>, A extends any, B extends any, CONDITION extends boolean = false> = T extends [infer X, ...infer Rest] ? CONDITION extends true ? X extends B ? [X, ...Slice<Rest, A, B, false>] : [X, ...Slice<Rest, A, B, true>] : X extends A ? X extends B ? [X, ...Slice<Rest, A, B, false>] : [X, ...Slice<Rest, A, B, true>] : Slice<Rest, A, B, false> : CONDITION extends true ? never : []; | ||
export type Take<T extends ReadonlyOrNot<any[]>, P extends number, R extends ReadonlyOrNot<any[]> = []> = Length<R> extends P ? R : T extends [infer F, ...infer Rest] ? Take<Rest, P, Push<R, F>> : R; | ||
export type TupleIncludes<T extends ReadonlyOrNot<any[]>, U> = T extends [infer P, ...infer R] ? Equal<U, P> extends true ? true : TupleIncludes<R, U> : false; | ||
export type TupleToUnion<T extends NTuple<number>> = T[number]; | ||
export type EntriesToObject<T extends Array<NTuple<2>>> = T extends [infer F, ...infer Rest] ? F extends [infer K extends string, infer V] ? Rest extends NTuple<2>[] ? Merge<Record<K, V>, EntriesToObject<Rest>> : never : never : {}; | ||
export type ArrayToUnion<T extends any[]> = T[number]; | ||
export type ArrayToUnion<T extends ReadonlyOrNot<any[]>> = T[number]; | ||
/** | ||
* PartitionByTwo<[1,2,3,4,5,6,7,8]> // [[1,2],[3,4],[5,6],[7,8]] | ||
*/ | ||
export type PartitionByTwo<T extends any[], L extends number = Length<T>> = T extends [ | ||
export type PartitionByTwo<T extends ReadonlyOrNot<any[]>, L extends number = Length<T>> = T extends [ | ||
infer First, | ||
@@ -52,23 +50,26 @@ infer Second, | ||
*/ | ||
export type Join<T extends readonly (string | number | boolean)[] | (string | number | boolean)[], U extends string = ','> = T extends readonly [infer F extends string | number | boolean, ...infer Rest extends (string | number | boolean)[]] ? Rest extends [] ? `${F}` : `${F}${U}${Join<Rest, U>}` : string; | ||
export type IsTuple<T extends readonly any[] | { | ||
export type Join<T extends ReadonlyOrNot<Exclude<Primitive, symbol>[]>, U extends string = ','> = T extends readonly [ | ||
infer F extends Exclude<Primitive, symbol>, | ||
...infer Rest extends ReadonlyOrNot<Exclude<Primitive, symbol>[]> | ||
] ? Rest extends [] ? `${F}` : `${F}${U}${Join<Rest, U>}` : string; | ||
export type IsTuple<T extends ReadonlyOrNot<any[]> | { | ||
length: number; | ||
}> = [T] extends [never] ? false : T extends readonly any[] ? number extends T['length'] ? false : true : false; | ||
}> = [T] extends [never] ? false : T extends ReadonlyOrNot<any[]> ? number extends T['length'] ? false : true : false; | ||
/** | ||
* Reverse<[1,2,3]> // [3,2,1] | ||
*/ | ||
export type Reverse<T extends any[]> = T extends [infer F, ...infer Rest] ? [...Reverse<Rest>, F] : []; | ||
export type Reverse<T extends ReadonlyOrNot<any[]>> = T extends [infer F, ...infer Rest] ? [...Reverse<Rest>, F] : []; | ||
/** | ||
* Shift<[1,2,3]> // [2,3] | ||
*/ | ||
export type Shift<T extends any[]> = T extends [infer F, ...infer Rest] ? Rest : []; | ||
export type Shift<T extends ReadonlyOrNot<any[]>> = T extends [infer F, ...infer Rest] ? Rest : []; | ||
/** | ||
* Unshift<[1, 2, 3], 4> // [4,1,2,3] | ||
*/ | ||
export type Unshift<T extends any[], V> = [V, ...T]; | ||
export type Unshift<T extends ReadonlyOrNot<any[]>, V> = [V, ...T]; | ||
/** | ||
* Pop<[1,2,3]> // [1,2] | ||
*/ | ||
export type Pop<T extends any[]> = T extends [...infer Rest, infer Last] ? Rest : []; | ||
export type Includes<T extends readonly any[], U> = T extends [infer P, ...infer R] ? Equal<U, P> extends true ? true : Includes<R, U> : false; | ||
export type Pop<T extends ReadonlyOrNot<any[]>> = T extends [...infer Rest, infer Last] ? Rest : []; | ||
export type Includes<T extends ReadonlyOrNot<any[]>, U> = T extends [infer P, ...infer R] ? Equal<U, P> extends true ? true : Includes<R, U> : false; | ||
/** | ||
@@ -79,5 +80,8 @@ * 튜플에서 중복 요소를 제거하는 타입 | ||
*/ | ||
export type Distinct<T extends any[], P extends any[] = []> = T extends [infer F, ...infer Rest] ? Includes<P, F> extends false ? Distinct<Rest, [...P, F]> : Distinct<Rest, P> : P; | ||
export type Distinct<T extends ReadonlyOrNot<any[]>, P extends ReadonlyOrNot<any[]> = []> = T extends [ | ||
infer F, | ||
...infer Rest | ||
] ? Includes<P, F> extends false ? Distinct<Rest, [...P, F]> : Distinct<Rest, P> : P; | ||
export type Compare<N1 extends number, N2 extends number> = N1 extends N2 ? true : [Sub<N1, N2>] extends [never] ? false : true; | ||
export type BubbleSort<T extends any[], L extends number = Length<T>, ASC extends boolean = false> = L extends 1 ? T : T extends [infer F, infer S, ...infer Rest] ? BubbleSort<[ | ||
export type BubbleSort<T extends ReadonlyOrNot<any[]>, L extends number = Length<T>, ASC extends boolean = false> = L extends 1 ? T : T extends [infer F, infer S, ...infer Rest] ? BubbleSort<[ | ||
...(Compare<NToNumber<F>, NToNumber<S>> extends ASC ? [F, ...BubbleSort<[S, ...Rest], Sub<L, 1>>] : [S, ...BubbleSort<[F, ...Rest], Sub<L, 1>>]) | ||
@@ -105,3 +109,3 @@ ], Sub<L, 1>> : never; | ||
} : never; | ||
export type At<Tuple extends any[] | readonly any[], Index extends number> = Tuple[Index]; | ||
export type At<Tuple extends ReadonlyOrNot<any[]>, Index extends number> = Tuple[Index]; | ||
//# sourceMappingURL=array.type.d.ts.map |
{ | ||
"name": "@kakasoo/proto-typescript", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
60464
115
628