tuples
v1.0.0
Published
A tiny tuple-like implementation in JavaScript.
Downloads
4
Readme
tuples
A tiny tuple-like implementation in JavaScript.
Installation
npm install tuples
Usage
const { tuple, fst, snd, swap } = require('tuples')
const t = tuple(1, 2) // => [1, 2]
fst(t) // => 1
snd(t) // => 2
swap(t) // => [2, 1]
API
t = tuple(...any)
Construct a new tuple.
fst(t)
Extract the first component of a pair.
snd(t)
Extract the second component of a pair.
swap(t)
Swap the components of a pair.