-
Notifications
You must be signed in to change notification settings - Fork 1
take
Subhajit Sahu edited this page Jun 20, 2020
·
15 revisions
Keeps first n values only. 🏃 📼 📦 🌔 📒
Alternatives: take, takeRight, takeWhile, takeWhileRight.
Similar: take, drop.
iterable.take(x, [n]);
// x: an iterable
// n: number of values (1)
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
[...iterable.take(x, 2)];
// [ 1, 2 ]
[...iterable.take(x, 3)];
// [ 1, 2, 3 ]