standard-data-structures
Version:
A collection of standard data-structures for node and browser
38 lines (37 loc) • 800 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const id_1 = require("../internals/id");
/**
* A tuple data-structure that can carry two values viz _0 and _1.
*/
class Tuple {
constructor(_0, _1) {
this._0 = _0;
this._1 = _1;
}
/**
* Creates a new instance of [[Tuple]]
*/
static of(_0, _1) {
return new Tuple(_0, _1);
}
/**
* Maps over both the first and the second value.
*/
biMap(LL, RR) {
return new Tuple(LL(this._0), RR(this._1));
}
/**
* Maps over the zeroth value
*/
map0(_0) {
return this.biMap(_0, id_1.id);
}
/**
* Maps over the first value
*/
map1(RR) {
return this.biMap(id_1.id, RR);
}
}
exports.Tuple = Tuple;