- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
take
        Subhajit Sahu edited this page Feb 3, 2021 
        ·
        15 revisions
      
    Keep first n values only.
Alternatives: take, takeRight, takeWhile, takeWhileRight.
Similar: take, drop.
function take(x, n)
// x: an iterable
// n: number of values [1]const xiterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
[...xiterable.take(x, 2)];
// → [1, 2]
[...xiterable.take(x, 3)];
// → [1, 2, 3]