drop-while-iterable

0.2.0 • Public • Published

drop-while-iterable

travis ci npm version Coverage Status Dependency Status

drop-while-iterable exports a class that builds iterables that provide dropWhile method.

Install

$ npm install drop-while-iterable --save

Usage

const I = require('drop-while-iterable') 
 
const first = I.of(new Set([4, 2, 7, 8, 4, 7])) // (4 2 7 8 4 7)
const second = I.dropWhile(e => e % 2 === 0, first) // (7 8 4 7)
const third = I.dropWhile(e => e > 5, second) // (4 7)
 
// converting to array:
[...third] // [4 7]
 
// traversing values:
for (const val of third) {
    // ...
}
 
// creating an iterator that traverses the values
let iterator = third[Symbol.iterator]()
iterator.next() // {value: 4, done: false}
iterator.next() // {value: 7, done: false}
iterator.next() // {value: undefined, done: true}
 
// Infinite iterable
const naturals = {
    [Symbol.iterator]: function* () {
        let i = 1
        while(true) { yield i++ }
    }
} // (1 2 3 4...)
 
I.dropWhile(e => e > 5, I.of(naturals)) // (6 7 8 9 10...)

Support

  • Node.js >=6
  • ES2015 transpilers

License

MIT

Package Sidebar

Install

npm i drop-while-iterable

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

8.32 kB

Total Files

4

Last publish

Collaborators

  • xgbuils