Git Product home page Git Product logo

pasync's Introduction

pasync

Version of async that uses promises instead of callbacks. Also includes other asynchronous promise utilities.

var pasync = require('pasync');

function getUserById(id) {
	return new Promise(...);
}

var userIds = [1, 2, 3, 4, 5, 6];

pasync.mapLimit(userIds, 2, getUserById).then(function(users) {
	// ...
});

You can also return values instead of promises from the iterator functions, and these will be converted into resolved promises. Exceptions thrown from iterator functions will be converted into rejected promises.

Additionally, this implements error handling for async functions that don't natively have error handling, such as async.filter .

Implemented Functions

  • each
  • eachSeries
  • eachLimit
  • map
  • mapSeries
  • mapLimit
  • filter
  • select
  • filterSeries
  • selectSeries
  • reject
  • rejectSeries
  • reduce
  • inject
  • foldl
  • reduceRight
  • foldr
  • detect
  • detectSeries
  • sortBy
  • some
  • every
  • concat
  • concatSeries
  • series
  • parallel
  • parallelLimit
  • whilst
  • doWhilst
  • until
  • doUntil
  • forever
  • waterfall
  • compose
  • seq
  • applyEach
  • applyEachSeries
  • queue
  • priorityQueue
  • cargo
  • auto
  • retry
  • apply
  • nextTick
  • times
  • timesSeries
  • memoize
  • unmemoize
  • log
  • dir

Neo-Async Functions Implemented

  • concatLimit
  • mapValues
  • mapValuesSeries
  • mapValuesLimit
  • detectLimit
  • everySeries
  • everyLimit
  • filterLimit
  • pick
  • pickSeries
  • pickLimit
  • rejectLimit
  • selectLimit
  • someSeries
  • someLimit
  • sortBySeries
  • sortByLimit
  • transform
  • transformSeries
  • transformLimit
  • timesLimit

Functions not implemented

  • iterator
  • noConflict

Other Utilities

abort(err)

This is intended to be used as a last-ditch error handler for promises. Using promises, if the last rejection handler in a promise throws an exception, it is silently ignored. Calling abort(err) will throw err as an exception in the global scope, calling the process's uncaughtException listeners or exiting with the exception by default. Use it like this:

getUser(nonexistent_id).then(function(user) {
	// do something with user
}).catch(function(err) {
	// Note the (obvious) errors in the rejection handlers; by default, this will be silently ignored
	cunsil.lug(err);
}).catch(pasync.abort);	// This will catch the undefined variable error and throw it globally

Contributors

  • crispy1989
  • crowelch

pasync's People

Contributors

crispyconductor avatar

Watchers

 avatar  avatar

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.