-
Notifications
You must be signed in to change notification settings - Fork 1
take
Subhajit Sahu edited this page May 13, 2020
·
15 revisions
Gets part of an iterable. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]
Alternatives: [take], [takeWhile].
Similar: [take], [drop].
iterable.slice(x, [i], [I]);
// x: an iterable
// i: start index (-ve: from right) (0)
// I: end index (-ve: from right) (end)
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 ]