Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ai-filter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-filter

Filter over async iterables.

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ai-filter

Travis Build Status NPM downloads

Filter over async iterables.

This method creates a new async iterable with all elements that pass the test implemented by the provided function.

Async iterable fun

This module is part of Async iterable fun, a complete toolset of modules to work with async iterables.

Usage

This example read a text file, filtering only chunks containing a new line:

import filter from 'ai-filter';
import { createReadStream } from "fs";

const stream = createReadStream(`file.txt`, "utf8");
const result = filter(chunk => chunk.contains('\n'), fromStream(stream))
for await (const chunk of result) {
  console.log(chunk);
}

API

index

The filter() method creates a new async iterable with all elements that pass the test implemented by the provided function.

Parameters

  • predicate Function is a predicate, to test each element of the async iterable. Return true to keep the element, false otherwise, taking three arguments:
        element: The current element being processed in the async iterable.
        index: The index of the current element being processed in the async iterable.
        iterable: The async iterable filter was called upon.
  • data AsyncIterable The source async iterable to filter.

Returns AsyncIterable A new async iterable with the elements that pass the test.

Install

With npm installed, run

npm install --save ai-filter

See Also

License

MIT

FAQs

Package last updated on 28 Nov 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc