Gathering detailed insights and metrics for typescript-tuple
Gathering detailed insights and metrics for typescript-tuple
Gathering detailed insights and metrics for typescript-tuple
Gathering detailed insights and metrics for typescript-tuple
downlevel-dts
Convert d.ts to be compatible with older typescript compilers
@bloomberg/record-tuple-polyfill
A polyfill for the Record and Tuple Stage 2 ECMAScript proposal.
meta-types
TypeScript meta functions for (especially variadic) meta programming
immutable-tuple
Immutable finite list objects with constant-time equality testing (===) and no memory leaks
npm install typescript-tuple
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
156 Stars
184 Commits
7 Forks
3 Watching
9 Branches
3 Contributors
Updated on 24 Oct 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-10.4%
154,499
Compared to previous day
Last week
-2%
849,925
Compared to previous week
Last month
6.7%
3,720,753
Compared to previous month
Last year
1.5%
42,331,860
Compared to previous year
1
Generics to work with tuples in TypeScript
IsFinite
1import { IsFinite } from 'typescript-tuple' 2 3type Foo = IsFinite<[0, 1, 2]> // Expect: true 4const foo: Foo = true 5 6type Bar = IsFinite<[0, 1, 2, ...number[]]> // Expect: false 7const bar: Bar = false 8 9type Baz = IsFinite<[0, 1, 2], 'finite', 'infinite'> // Expect: 'finite' 10const baz: Baz = 'finite'
First
1import { First } from 'typescript-tuple' 2type Foo = First<['a', 'b', 'c']> // Expect: 'a' 3const foo: Foo = 'a'
Last
1import { Last } from 'typescript-tuple' 2type Foo = Last<['a', 'b', 'c']> // Expect: 'c' 3const foo: Foo = 'c'
Tail
1import { Tail } from 'typescript-tuple' 2type Foo = Tail<['a', 'b', 'c']> // Expect: ['b', 'c'] 3const foo: Foo = ['b', 'c']
Append
1import { Append } from 'typescript-tuple' 2type Foo = Append<['a', 'b', 'c'], 'x'> // Expect: ['a', 'b', 'c', 'x'] 3const foo: Foo = ['a', 'b', 'c', 'x']
Prepend
1import { Prepend } from 'typescript-tuple' 2type Foo = Prepend<['a', 'b', 'c'], 'x'> // Expect: ['x', 'a', 'b', 'c'] 3const foo: Foo = ['x', 'a', 'b', 'c']
Reverse
1import { Reverse } from 'typescript-tuple' 2type Foo = Reverse<['a', 'b', 'c']> // Expect: ['c', 'b', 'a'] 3const foo: Foo = ['c', 'b', 'a']
Concat
1import { Concat } from 'typescript-tuple' 2type Foo = Concat<['a', 'b', 'c'], [0, 1, 2]> // Expect ['a', 'b', 'c', 0, 1, 2] 3const foo: Foo = ['a', 'b', 'c', 0, 1, 2]
Repeat
1import { Repeat } from 'typescript-tuple' 2 3// Basic 4type Foo = Repeat<'x', 5> // Expect ['x', 'x', 'x', 'x', 'x'] 5const foo: Foo = ['x', 'x', 'x', 'x', 'x'] 6 7// Using union 8type Bar = Repeat<'x', 1 | 3 | 4> // Expect ['x'] | ['x', 'x', 'x'] | ['x', 'x', 'x', 'x'] 9const bar1: Bar = ['x'] 10const bar3: Bar = ['x', 'x', 'x'] 11const bar4: Bar = ['x', 'x', 'x', 'x'] 12 13// Using ambiguous 'number' type 14type Baz = Repeat<'x', number> // Expect 'x'[] 15const baz: Baz = Array<number>()
NOTES:
ConcatMultiple
1import { ConcatMultiple } from 'typescript-tuple' 2type Foo = ConcatMultiple<[[], ['a'], ['b', 'c']]> // Expect ['a', 'b', 'c'] 3const foo: Foo = ['a', 'b', 'c']
Drop
1import { Drop } from 'typescript-tuple' 2 3type Foo = Drop<[0, 1, 2, 3, 4], 2> // Expect [2, 3, 4] 4const foo: Foo = [2, 3, 4] 5 6type Bar = Drop<[0, 1, 2, 3, 4, ...number[]], 2> // Expect [2, 3, 4, ...number[]] 7const bar: Bar = [2, 3, 4] 8 9type Baz = Drop<[0, 1, 2, 3, 4], 10> // Expect [] 10const baz: Baz = [2, 3, 4] 11 12type Qux = Drop<[0, 1, 2, 3, 4, ...number[]], 10> // Expect number[] 13const qux: Qux = [2, 3, 4]
SliceStartQuantity
1import { SliceStartQuantity } from 'typescript-tuple' 2type Foo = SliceStartQuantity<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4> // Expect [2, 3, 4, 5] 3const foo: Foo = [2, 3, 4, 5]
FillTuple
1import { FillTuple } from 'typescript-tuple' 2type Foo = FillTuple<[0, 1, 2, 3], 'r'> 3const foo: Foo = ['r', 'r', 'r', 'r']
CompareLength
1import { CompareLength } from 'typescript-tuple' 2 3type Foo = CompareLength<[0, 1, 2], ['a', 'b', 'c']> // Expect: 'equal' 4const foo: Foo = 'equal' 5 6type Bar = CompareLength<[0, 1], ['a', 'b', 'c', 'd']> // Expect: 'shorterLeft' 7const bar: Bar = 'shorterLeft' 8 9type Baz = CompareLength<[0, 1, 2, 3], ['a', 'b']> // Expect: 'shorterRight' 10const baz: Baz = 'shorterRight'
SortTwoTuple
1import { SortTwoTuple } from 'typescript-tuple' 2 3type Foo = SortTwoTuple<[0, 1], ['a', 'b', 'c', 'd']> // Expect: [[0, 1], ['a', 'b', 'c', 'd']] 4const foo: Foo = [[0, 1], ['a', 'b', 'c', 'd']] 5 6type Bar = SortTwoTuple<[0, 1, 2, 3], ['a', 'b']> // Expect: [['a', 'b'], [0, 1, 2, 3]] 7const bar: Bar = [['a', 'b'], [0, 1, 2, 3]] 8 9type Baz = SortTwoTuple<[0, 1, 2], ['a', 'b', 'c', 'd']> // Expect: [[0, 1, 2], ['a', 'b', 'c']] 10const baz: Baz = [[0, 1], 3, ['a', 'b', 'c']] 11 12type Qux = SortTwoTuple<[0, 1, 2], ['a', 'b', 'c', 'd'], 'EQUAL'> // Expect: 'EQUAL' 13const qux: Qux = 'EQUAL'
ShortestTuple
1import { ShortestTuple } from 'typescript-tuple' 2 3type Foo = ShortestTuple<[[0, 1, 2], [false, true], ['a', 'b', 'c', 'd']]> // Expect: [false, true] 4const foo: Foo = [false, true] 5 6type Bar = ShortestTuple<[[0, 1, 2], ['a', 'b', 'c'], ...[false, true][]]> // Expect: [false, true] 7const bar: Bar = [false, true]
LongestTuple
1import { LongestTuple } from 'typescript-tuple' 2 3type Foo = LongestTuple<[[0, 1, 2, 3], [false, true], ['a']]> // Expect: [0, 1, 2, 3] 4const foo: Foo = [0, 1, 2, 3] 5 6type Bar = LongestTuple<[[], [false, true], ...[0, 1, 2][]]> // Expect: [0, 1, 2] 7const bar: Bar = [0, 1, 2]
FilterTuple
1import { FilterTuple } from 'typescript-tuple' 2 3type Foo = FilterTuple<[1, '1'], number> // Expect: [1] 4const foo: Foo = [1] 5 6type Bar = FilterTuple<[1, '1', null, true], 1 | '1' | true> // Expect: [1, '1', true] 7const bar: Bar = [1, '1', true]
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 1/21 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More