typescript-tuple
Advanced tools
Comparing version 3.0.0-rc to 3.0.0-rc.0
@@ -119,2 +119,9 @@ import * as utils from './utils'; | ||
/** | ||
* Drop `Quantity` first elements of a tuple | ||
* @example Drop<['a', 'b', 'c', 'd', 'e'], 2> → ['c', 'd', 'e'] | ||
* @example Drop<['a', 'b', 'c', 'd', 'e', ...string[]], 2> → ['c', 'd', 'e', ...string[]] | ||
* @example Drop<['a', 'b', 'c', 'd', 'e', ...string[]], 10> → string[] | ||
*/ | ||
export declare type Drop<Tuple extends any[], Quantity extends number> = utils.Drop<Tuple, Quantity>; | ||
/** | ||
* Slice a tuple | ||
@@ -121,0 +128,0 @@ * @example SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6], 2, 3> → [2, 3, 4] |
@@ -87,2 +87,6 @@ import { Extends, Equal } from 'typescript-compare'; | ||
}[TupleSet extends [] ? 'empty' : IsFinite<TupleSet, 'nonEmpty', 'infinite'>]; | ||
export declare type Drop<Tuple extends any[], Quantity extends number, Count extends any[] = []> = { | ||
matched: Tuple; | ||
unmatched: ((...args: Tuple) => any) extends ((_: any, ..._1: infer Rest) => any) ? Drop<Rest, Quantity, Prepend<Count, Count['length']>> : never; | ||
}[Tuple extends [] ? 'matched' : Quantity extends Count['length'] ? 'matched' : 'unmatched']; | ||
export declare type SliceStartQuantity<Tuple extends any[], Start extends number, Quantity extends number, Holder extends any[] = [], Count extends any[] = []> = { | ||
@@ -89,0 +93,0 @@ before: SliceStartQuantity<Tail<Tuple>, Start, Quantity, Holder, Prepend<Count, Count['length']>>; |
{ | ||
"name": "typescript-tuple", | ||
"version": "3.0.0-rc", | ||
"version": "3.0.0-rc.0", | ||
"description": "Generics to work with tuples in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -246,2 +246,20 @@ # TypeScript Tuple | ||
### `Drop` | ||
```typescript | ||
import { Drop } from 'typescript-tuple' | ||
type Foo = Drop<[0, 1, 2, 3, 4], 2> // Expect [2, 3, 4] | ||
const foo: Foo = [2, 3, 4] | ||
type Bar = Drop<[0, 1, 2, 3, 4, ...number[]], 2> // Expect [2, 3, 4, ...number[]] | ||
const bar: Bar = [2, 3, 4] | ||
type Baz = Drop<[0, 1, 2, 3, 4], 10> // Expect [] | ||
const baz: Baz = [2, 3, 4] | ||
type Qux = Drop<[0, 1, 2, 3, 4, ...number[]], 10> // Expect number[] | ||
const qux: Qux = [2, 3, 4] | ||
``` | ||
### `SliceStartQuantity` | ||
@@ -248,0 +266,0 @@ |
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
32260
299
352