You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

transduce-async

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transduce-async

Async transducers with Promises, defer, delay

Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
5
-80.77%
Maintainers
1
Weekly downloads
 
Created
Source

Transduce Async

Build Status

Use Transducers with async iterators and observables by supporting Promises in iterators and transformers. Inspired by this talk from Erik Meijer.

Works with transduce, transducers-js or transducers.js.

Also works with any-promise library (a pollyfill, es6-promise, promise, native-promise-only, bluebird, rsvp, when, q).

Just install your transducers and Promise library preference and it will be auto detected and used.

API:

defer: function();
delay: function(wait);
compose: function(/*args*/);
transduce: function(xf, f, init, coll);
reduce: function(f, init, coll);
toArray: function(xf?, coll);

defer

Create a deferred transducer that allows wrapped transformer to step or result a Promise in addition to a value. All items will be queued and processed in order. The wrapped transformer is called with value of resolved Promise.

delay

Create a deferred transducer that delays step of wrapped transformer by wait milliseconds. All items will be queued and delayed and step will return a promise that will resolve after wait milliseconds for each item.

compose

Like a normal compose, except all arguments are interleaved with defer. This allows any transducer in composed pipeline to step or result a Promise in addition to a value. The wrapped transformer is called with value of resolved Promise.

transduce

Like a normal transduce, except init and coll can be a Promise and xf can be a deferred transducer. The value of coll can be anything that can be converted to an iterator. The return value is a Promise for the result of the transformation.

reduce

Like a normal reduce, except init and coll can be a Promise and xf can be a deferred transducer. The value of coll can be anything that can be converted to an iterator. The return value is a Promise for the result of the reduction.

toArray

Convenience function to transduce into an array with an optional transformation. The return value is a Promise for an array.

Keywords

transducer

FAQs

Package last updated on 11 Jan 2015

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