Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-tuple

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-tuple - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

12

lib/index.d.ts

@@ -26,2 +26,7 @@ import * as utils from './utils';

/**
* Drop the first element
* @example Tail<[0, 1, 2, 3]> → [1, 2, 3]
*/
export declare type Tail<Tuple extends any[]> = utils.Tail<Tuple>;
/**
* Find index of a type in tuple

@@ -115,2 +120,9 @@ * @example FirstIndexEqual<'x', ['a', 'b', 'c', 'x', 'd']> → 3

/**
* Slice a tuple
* @example SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6], 2> → [2, 3, 4, 5, 6]
* @example SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6], 2, 3> → [2, 3, 4]
* @example SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6], 2, 9> → [2, 3, 4, 5, 6]
*/
export declare type SliceStartQuantity<Tuple extends any[], Start extends number, Quantity extends number = Tuple['length']> = utils.SliceStartQuantity<Tuple, Start, Quantity>;
/**
* Create a set of tuple of single element

@@ -117,0 +129,0 @@ * @example SingleTupleSet<[0, 1, 2]> → [[0], [1], [2]]

@@ -20,2 +20,3 @@ import { Extends, Equal } from 'typescript-compare';

}[Tuple extends [] ? 'empty' : Tuple extends [any] ? 'single' : Tuple extends (infer Element)[] ? Element[] extends Tuple ? 'infinite' : 'multi' : never];
export declare type Tail<Tuple extends any[]> = ((...args: Tuple) => any) extends ((_: any, ..._1: infer Rest) => any) ? Rest : never;
export declare type FirstIndexEqual<Type, Tuple extends any[], NotFound = never, Count extends any[] = []> = {

@@ -87,2 +88,7 @@ empty: NotFound;

}[TupleSet extends [] ? 'empty' : IsFinite<TupleSet, 'nonEmpty', 'infinite'>];
export declare type SliceStartQuantity<Tuple extends any[], Start extends number, Quantity extends number, Holder extends any[] = [], Count extends any[] = []> = {
before: SliceStartQuantity<Tail<Tuple>, Start, Quantity, Holder, Prepend<Count, Count['length']>>;
start: ((...args: Tuple) => any) extends ((_: infer First, ..._1: infer Rest) => any) ? SliceStartQuantity<Rest, Start, Quantity, Prepend<Holder, First>, Count> : never;
end: Reverse<Holder>;
}[Tuple extends [] ? 'end' : Quantity extends Holder['length'] ? 'end' : Start extends Count['length'] ? 'start' : 'before'];
export declare type SingleTupleSet<Types extends any[], Holder extends [any][] = []> = {

@@ -89,0 +95,0 @@ empty: Holder;

4

package.json
{
"name": "typescript-tuple",
"version": "2.1.1",
"version": "2.2.0",
"description": "Generics to work with tuples in TypeScript",

@@ -39,4 +39,4 @@ "main": "index.js",

"toolcheck": "^0.0.5",
"clean-typescript-build": "^0.0.7"
"clean-typescript-build": "^0.1.0"
}
}

@@ -54,2 +54,10 @@ # TypeScript Tuple

### `Tail`
```typescript
import { Tail } from 'typescript-tuple'
type Foo = Tail<['a', 'b', 'c']> // Expect: ['b', 'c']
const foo: Foo = ['b', 'c']
```
### `FirstIndexEqual`

@@ -239,2 +247,10 @@

### `SliceStartQuantity`
```typescript
import { SliceStartQuantity } from 'typescript-tuple'
type Foo = SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4> // Expect [2, 3, 4, 5]
const foo: Foo = [2, 3, 4, 5]
```
### `SingleTupleSet`

@@ -241,0 +257,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc