New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

buffer-async-iterator

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

buffer-async-iterator

Buffer an AsyncIterator before iteration.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

buffer-async-iterator

Buffer an AsyncIterator before iteration.

Create an AsyncIterator over the values of an AsyncIterator, eagerly iterated.

Install

$ yarn buffer-async-iterator

API

Table of Contents

  • bufferAsyncIterator

bufferAsyncIterator

Create an AsyncIterator from iterable, with the values eagerly buffered.

Parameters

  • iterable (AsyncIterable<Value> | Iterable<Value>) The iterable whose values will be buffered.
  • write Write A function that takes iterable and buffer and returns a Promise. buffer will not be iterated through until it resolves. (optional, default defaultWrite)
  • buffer (AsyncIterable<Value> | Iterable<Value>) An iterable representing the data being buffered. (optional, default [])

Examples

import bufferAsyncIterator from 'bufferAsyncIterator';
import got from 'got';

async function* getWebsites(sites) {
  for (const site of sites) {
    yield await got(site);
  }
}

// Immediate start running the generator.
const websiteIterator = bufferAsyncIterator(getWebsites(['google.com', 'bing.com', 'is-yahoo-still-around.com']));

for await (const site of websiteIterator) {
  // Iteration begins only after the original generator has finished.
}

License

MIT © Matthew Fernando Garcia

FAQs

Package last updated on 03 Jun 2018

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