Coder Social home page Coder Social logo

iterated-pipes's Introduction

Iterated Pipes

Iterator based utilities for handling sync & async tasks like async execution with a maximum for parallel tasks at the same time.

Don't get fooled by this repository last update, this repository is maintained and we use it daily where I work. It is just that we aren't having any bugs.

Build Status Coverage Status Code Climate npm version

Index

Methods

This library is based in iterators, that means, it can work over everything that is iterable (arrays, generators, strings, ...). Just use the static method iterate and select the method. There is two basic patters here: sequential and parallel (witch admits a maximum of concurrency).

sequential

Execute the promises one after the other, always waiting to the previous one to finish before executing the next Promise.

	var piped = require('iterated-pipes');

	piped
	.iterate([...])
	.sequential(url => request(url))
	.then(lastValue => {...});

parallel

Iterate all the items and return an array with the results. Is like a Promise.all but accepts a maximum quantity of maximum executions in parallel.

	var piped = require('iterated-pipes');

	piped
	.iterate([...])
	.parallel(10, url => request(url)) //Executes a maximum of 10 calls at a time. When one call ends, call the next one
	.then(results => {...}); //All the results in the same order

Is important to make a distinction between this method and the ones that use Promise.all internally. This one executes the next call just after one call is finish meanwhile other methods execute X callbacks with Promise.all, waiting until the last one to continue the execution, making these methods less time efficient.

iterated-pipes's People

Contributors

davidbm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iterated-pipes's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.