Socket
Socket
Sign inDemoInstall

@n1ru4l/push-pull-async-iterable-iterator

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@n1ru4l/push-pull-async-iterable-iterator

[![Build Status](https://img.shields.io/github/workflow/status/n1ru4l/push-pull-async-iterable-iterator/CI)](https://github.com/n1ru4l/push-pull-async-iterable-iterator/actions) [![npm version](https://img.shields.io/npm/v/@n1ru4l/push-pull-async-iterable


Version published
Weekly downloads
291K
increased by21.17%
Maintainers
1
Weekly downloads
 
Created

What is @n1ru4l/push-pull-async-iterable-iterator?

@n1ru4l/push-pull-async-iterable-iterator is a utility library for creating and working with async iterable iterators in a push-pull fashion. It allows you to easily create async iterators that can be pushed to and pulled from, making it useful for scenarios like handling streams of data, event handling, and more.

What are @n1ru4l/push-pull-async-iterable-iterator's main functionalities?

Creating a Push-Pull Async Iterable Iterator

This feature allows you to create an async iterable iterator that you can push values to and pull values from. The example demonstrates creating an iterator, pushing values to it, and iterating over those values asynchronously.

const { createPushPullAsyncIterableIterator } = require('@n1ru4l/push-pull-async-iterable-iterator');

const { asyncIterableIterator, pushValue, stop } = createPushPullAsyncIterableIterator();

(async () => {
  for await (const value of asyncIterableIterator) {
    console.log(value);
  }
})();

pushValue(1);
pushValue(2);
pushValue(3);
stop();

Handling Errors

This feature allows you to handle errors within the async iterable iterator. The example demonstrates pushing an error to the iterator and handling it within the async iteration loop.

const { createPushPullAsyncIterableIterator } = require('@n1ru4l/push-pull-async-iterable-iterator');

const { asyncIterableIterator, pushValue, pushError, stop } = createPushPullAsyncIterableIterator();

(async () => {
  try {
    for await (const value of asyncIterableIterator) {
      console.log(value);
    }
  } catch (error) {
    console.error('Error:', error);
  }
})();

pushValue(1);
pushError(new Error('Something went wrong!'));
stop();

Stopping the Iterator

This feature allows you to stop the async iterable iterator. The example demonstrates pushing values to the iterator and then stopping it, which ends the iteration loop.

const { createPushPullAsyncIterableIterator } = require('@n1ru4l/push-pull-async-iterable-iterator');

const { asyncIterableIterator, pushValue, stop } = createPushPullAsyncIterableIterator();

(async () => {
  for await (const value of asyncIterableIterator) {
    console.log(value);
  }
  console.log('Iterator stopped');
})();

pushValue(1);
pushValue(2);
stop();

Other packages similar to @n1ru4l/push-pull-async-iterable-iterator

FAQs

Package last updated on 24 Nov 2020

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