TypeScript Tuple
Generics to work with tuples in TypeScript
Requirements
Usage
First
import { First } from 'typescript-tuple'
type Foo = First<['a', 'b', 'c']>
const foo: Foo = 'a'
Last
import { Last } from 'typescript-tuple'
type Foo = Last<['a', 'b', 'c']>
const foo: Foo = 'c'
Append
import { Append } from 'typescript-tuple'
type Foo = Append<['a', 'b', 'c'], 'x'>
const foo: Foo = ['a', 'b', 'c', 'x']
Prepend
import { Prepend } from 'typescript-tuple'
type Foo = Prepend<['a', 'b', 'c'], 'x'>
const foo: Foo = ['x', 'a', 'b', 'c']
Reverse
import { Reverse } from 'typescript-tuple'
type Foo = Reverse<['a', 'b', 'c']>
const foo: Foo = ['c', 'b', 'a']
Concat
import { Concat } from 'typescript-tuple'
type Foo = Concat<['a', 'b', 'c'], [0, 1, 2]>
const foo: Foo = ['a', 'b', 'c', 0, 1, 2]
Repeat
import { Repeat } from 'typescript-tuple'
type Foo = Repeat<['x'], 5>
const foo: Foo = ['x', 'x', 'x', 'x', 'x']
ConcatMultiple
import { ConcatMultiple } from 'typescript-tuple'
type Foo = ConcatMultiple<[[], ['a'], ['b', 'c']]>
const foo: Foo = ['a', 'b', 'c']
License
MIT @ Hoàng Văn Khải