-
Notifications
You must be signed in to change notification settings - Fork 0
take
Subhajit Sahu edited this page Dec 22, 2022
·
15 revisions
Keep first n values only.
function take(x, n?)
// x: an iterable
// n: number of values [1]
const ientries = require('extra-ientries');
var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]];
[...ientries.take(x, 2)];
// → [ [ "a", 1 ], [ "b", 2 ] ]
[...ientries.take(x, 3)];
// → [ [ "a", 1 ], [ "b", 2 ], [ "c", 3 ] ]