Socket
Book a DemoInstallSign in
Socket

@iterables/filter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iterables/filter

a filter function for iterables

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
592
453.27%
Maintainers
1
Weekly downloads
 
Created
Source

@iterables/filter

A filter generator for iterators.


const filter = require('@iterables/filter')

const iter = filter(function * () {
  yield 1
  yield 2
}(), xs => xs % 2 === 0)

console.log([...iter]) // [2]

Installation

$ npm install --save @iterables/filter

API

filter(iterable, fn) -> Iterator

  • iterable: any Iterator — a generator instance, Array, Map, String, or Set
  • fn: A function taking xs, idx, and all and returning a boolean value.
    • xs: an item from iterable.
    • idx: a number reflecting the index of the current item.
    • all: the full iterable object.

Returns a filtered iterator. Pretty standard stuff!

License

MIT

FAQs

Package last updated on 08 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts