cspotcode / cspotcode/typescript-toolbelt

Add tuple manipulators

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
19
Forks
0
PR merge metrics
No merged PRs in 30d

Description

EDIT: base these on, or simply re-export, the tuple helpers from https://github.com/ksxnodemodules/typescript-tuple

Tuple slicing helpers.

Tuple equivalents of

* slice(0, -1)
* slice(1)
* extract first item
* extract last item
* extract arity of a tuple as a numeric literal?

```
type TupleOmitLast =
T extends [infer A, infer B, infer C, infer D, infer E, infer F, infer G, infer H]
? [A, B, C, D, E, F, G]
: T extends [infer A, infer B, infer C, infer D, infer E, infer F, infer G]
? [A, B, C, D, E, F]
: T extends [infer A, infer B, infer C, infer D, infer E, infer F]
? [A, B, C, D, E]
: T extends [infer A, infer B, infer C, infer D, infer E]
? [A, B, C, D]
: T extends [infer A, infer B, infer C, infer D]
? [A, B, C]
: T extends [infer A, infer B, infer C]
? [A, B]
: T extends [infer A, infer B]
? [A]
: T extends [infer A]
? []
: unknown;
```

Utilities to replace a single element of a tuple.
For example, convert [A, B, C] -> [A, T, C]

To union a single element? To Exclude? To Extract?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.