Skip to content
This repository was archived by the owner on Aug 3, 2023. It is now read-only.

Remove unusable APIs #24

Merged
merged 2 commits into from
Aug 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 0 additions & 144 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ type Baz = IsFinite<[0, 1, 2], 'finite', 'infinite'> // Expect: 'finite'
const baz: Baz = 'finite'
```

### `SplitInfiniteTuple`

```typescript
import { SplitInfiniteTuple } from 'typescript-tuple'
type Foo = SplitInfiniteTuple<[0, 1, 2, ...number[]]> // Expect: [[0, 1, 2], number[]]
type FinitePart = Foo[0] // Expect: [0, 1, 2]
type InfinitePart = Foo[1] // Expect: number[]
const foo: Foo = [[0, 1, 2], Array<number>()]
const finitePart: FinitePart = [0, 1, 2]
const infinitePart: InfinitePart = Array<number>()
```

### `First`

```typescript
Expand All @@ -59,126 +47,6 @@ type Foo = Tail<['a', 'b', 'c']> // Expect: ['b', 'c']
const foo: Foo = ['b', 'c']
```

### `FirstIndexEqual`

```typescript
import { FirstIndexEqual } from 'typescript-tuple'

type Foo = FirstIndexEqual<'x', ['a', 'x', 'b', 'x']> // Expect: 1
const foo: Foo = 1

type Bar = FirstIndexEqual<'x', ['a', 'b']> // Expect: never

type Baz = FirstIndexEqual<'x', ['a', 'b'], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `FirstIndexSubset`

```typescript
import { FirstIndexSubset } from 'typescript-tuple'

type Foo = FirstIndexSubset<string, [0, 'a', 1, 'b']> // Expect: 1
const foo: Foo = 1

type Bar = FirstIndexSubset<string, [0, 1]> // Expect: never

type Baz = FirstIndexSubset<string, [0, 1], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `FirstIndexSuperset`

```typescript
import { FirstIndexSuperset } from 'typescript-tuple'

type Foo = FirstIndexSuperset<'x', [number, string, 0 | 1, 'x' | 'y']> // Expect: 1
const foo: Foo = 1

type Bar = FirstIndexSuperset<'x', [number, 0 | 1]> // Expect: never

type Baz = FirstIndexSuperset<'x', [number, 0 | 1], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `LastIndexEqual`

```typescript
import { LastIndexEqual } from 'typescript-tuple'

type Foo = LastIndexEqual<'x', ['a', 'x', 'b', 'x']> // Expect: 3
const foo: Foo = 3

type Bar = LastIndexEqual<'x', ['a', 'b']> // Expect: never

type Baz = LastIndexEqual<'x', ['a', 'b'], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `LastIndexSubset`

```typescript
import { LastIndexSubset } from 'typescript-tuple'

type Foo = LastIndexSubset<string, [0, 'a', 1, 'b']> // Expect: 3
const foo: Foo = 3

type Bar = LastIndexSubset<string, [0, 1]> // Expect: never

type Baz = LastIndexSubset<string, [0, 1], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `LastIndexSuperset`

```typescript
import { LastIndexSuperset } from 'typescript-tuple'

type Foo = LastIndexSuperset<'x', [number, string, 0 | 1, 'x' | 'y']> // Expect: 3
const foo: Foo = 3

type Bar = LastIndexSuperset<'x', [number, 0 | 1]> // Expect: never

type Baz = LastIndexSuperset<'x', [number, 0 | 1], 'not found'> // Expect: 'not found'
const baz: Baz = 'not found'
```

### `AllIndexesEqual`

```typescript
import { AllIndexesEqual } from 'typescript-tuple'

type Foo = AllIndexesEqual<'x', ['a', 'x', 'b', 'x']> // Expect: [1, 3]
const foo: Foo = [1, 3]

type Bar = AllIndexesEqual<'x', ['a', 'x', 'b', ...'x'[]]> // Expect: [1, ...3[]]
const bar: Bar = [1, 3, 3, 3, 3]
```

### `AllIndexesSubset`

```typescript
import { AllIndexesSubset } from 'typescript-tuple'

type Foo = AllIndexesSubset<string, [0, 'a', 1, 'b']> // Expect: [1, 3]
const foo: Foo = [1, 3]

type Bar = AllIndexesSubset<string, [0, 'a', 1, ...'b'[]]> // Expect: [1, ...3[]]
const bar: Bar = [1, 3, 3, 3, 3]
```

### `AllIndexesSuper`

```typescript
import { AllIndexesSuper } from 'typescript-tuple'

type Foo = AllIndexesSuper<'x', [number, string, 0 | 1, 'x' | 'y']> // Expect: [1, 3]
const foo: Foo = [1, 3]

type Bar = AllIndexesSuper<'x', [number, string, 0 | 1, ...'x'[]]> // Expect: [1, ...3[]]
const bar: Bar = [1, 3, 3, 3, 3]
```

### `Append`

```typescript
Expand Down Expand Up @@ -269,18 +137,6 @@ type Foo = SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4> // Expect [2
const foo: Foo = [2, 3, 4, 5]
```

### `SingleTupleSet`

```typescript
import { SingleTupleSet } from 'typescript-tuple'

type Foo = SingleTupleSet<[0, 1, 2]> // Expect [[0], [1], [2]]
const foo: Foo = [[0], [1], [2]]

type Bar = SingleTupleSet<'x'[]> // Expect ['x'][]
const bar: Bar = Array<['x']>()
```

### `FillTuple`

```typescript
Expand Down
88 changes: 0 additions & 88 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import * as utils from './utils'
export type IsFinite<Tuple extends any[], Finite = true, Infinite = false> =
utils.IsFinite<Tuple, Finite, Infinite>

/**
* Split an infinite tuple into a finite tuple and an array
* @example SplitInfiniteTuple<[0, 1, 2, ...number[]]> → [[0, 1, 2], number[]]
*/
export type SplitInfiniteTuple<Tuple extends any[]> = utils.SplitInfiniteTuple<Tuple>

/**
* Get type of first element
* @example First<[0, 1, 2]> → 0
Expand All @@ -34,81 +28,6 @@ export type Last<Tuple extends any[]> = utils.Last<Tuple>
*/
export type Tail<Tuple extends any[]> = utils.Tail<Tuple>

/**
* Find index of a type in tuple
* @example FirstIndexEqual<'x', ['a', 'b', 'c', 'x', 'd']> → 3
* @example FirstIndexEqual<'x', ['a', 'b', 'c']> → never
* @example FirstIndexEqual<'x', ['a', 'b', 'c'], 'NotFound'> → 'NotFound'
*/
export type FirstIndexEqual<Type, Tuple extends any[], NotFound = never> =
utils.FirstIndexEqual<Type, Tuple, NotFound>

/**
* Find index of the first element in tuple that satifies a type
* @example FirstIndexSubset<string, [true, false, 'x', 3]> → 2
* @example FirstIndexSubset<string, [true, false, 0, 1]> → never
* @example FirstIndexSubset<string, [true, false, 0, 1], 'NotFound'> → 'NotFound'
*/
export type FirstIndexSubset<Type, Tuple extends any[], NotFound = never> =
utils.FirstIndexSubset<Type, Tuple, NotFound>

/**
* Find index of the first element in tuple that satifies a type
* @example FirstIndexSuperset<5, [boolean, string, number, object]> → 2
* @example FirstIndexSuperset<5, [boolean, string, object]> → never
* @example FirstIndexSuperset<5, [boolean, string, object], 'NotFound'> → 'NotFound'
*/
export type FirstIndexSuperset<Type, Tuple extends any[], NotFound = never> =
utils.FirstIndexSuperset<Type, Tuple, NotFound>

/**
* Find index of a type in tuple
* @example LastIndexEqual<'x', ['a', 'b', 'c', 'x', 'd']> → 3
* @example LastIndexEqual<'x', ['a', 'b', 'c']> → never
* @example LastIndexEqual<'x', ['a', 'b', 'c'], 'NotFound'> → 'NotFound'
*/
export type LastIndexEqual<Type, Tuple extends any[], NotFound = never> =
utils.LastIndexEqual<Type, Tuple, NotFound>

/**
* Find index of the first element in tuple that satifies a type
* @example LastIndexSubset<string, [true, false, 'x', 3]> → 2
* @example LastIndexSubset<string, [true, false, 0, 1]> → never
* @example LastIndexSubset<string, [true, false, 0, 1], 'NotFound'> → 'NotFound'
*/
export type LastIndexSubset<Type, Tuple extends any[], NotFound = never> =
utils.LastIndexSubset<Type, Tuple, NotFound>

/**
* Find index of the first element in tuple that satifies a type
* @example LastIndexSuperset<5, [boolean, string, number, object]> → 2
* @example LastIndexSuperset<5, [boolean, string, object]> → never
* @example LastIndexSuperset<5, [boolean, string, object], 'NotFound'> → 'NotFound'
*/
export type LastIndexSuperset<Type, Tuple extends any[], NotFound = never> =
utils.LastIndexSuperset<Type, Tuple, NotFound>

/**
* Find all indexes of a type in tuple
* @example AllIndexesEqual<'x', ['a', 'b', 'x', 'c', 'x', 'x']> → [2, 4, 5]
*/
export type AllIndexesEqual<Type, Tuple extends any[]> =
utils._IndexesNormalize<utils._AllIndexesEqual<Type, Tuple>>

/**
* Find all indexes of a type in tuple
* @example AllIndexesSubset<string, [0, false, 'a', 1, 'b', 'c']> → [2, 4, 5]
*/
export type AllIndexesSubset<Type, Tuple extends any[]> =
utils._IndexesNormalize<utils._AllIndexesSubset<Type, Tuple>>

/**
* Find all indexes of a type in tuple
* @example AllIndexesSuperset<'x', [number, boolean, string, 0, 'x', 'a' | 'b']> → [2, 4, 5]
*/
export type AllIndexesSuperset<Type, Tuple extends any[]> =
utils._IndexesNormalize<utils._AllIndexesSuperset<Type, Tuple>>

/**
* Add an element to the end of a tuple
* @example Append<[0, 1, 2], 'new'> → [0, 1, 2, 'new']
Expand Down Expand Up @@ -165,13 +84,6 @@ export type SliceStartQuantity<
Quantity extends number
> = utils.SliceStartQuantity<Tuple, Start, Quantity>

/**
* Create a set of tuple of single element
* @example SingleTupleSet<[0, 1, 2]> → [[0], [1], [2]]
* @example SingleTupleSet<[0, 1, 2, ...number[]]> → [[0], [1], [2], ...[number][]]
*/
export type SingleTupleSet<Types extends any[]> = utils.SingleTupleSet<Types>

/**
* Fill a tuple of types
* @example FillTuple<[0, 1, 2], 'x'> → ['x', 'x', 'x']
Expand Down
Loading