head - nodef/extra-entries GitHub Wiki

Get first value.

Similar: head, tail.

function head(x, vd?)
// x:  an iterable
// vd: default value
const entries = require('extra-entries');

var x = ["a", 1], ["b", 2], ["c", 3](/nodef/extra-entries/wiki/"a",-1],-["b",-2],-["c",-3);
entries.head(x);
// → [ "a", 1 ]

var x = [];
entries.head(x, ["", -1]);
// → [ "", -1 ]

References