npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qall

v1.0.0

Published

lift functions of arity > 1 into a Promises/A+ chain

Downloads

13

Readme

qall

lift functions of any arity into a Promises/A+ chain

usage example

var qall = require('qall')
var await = require('qall').await
var join = require('qall').join

function assertEq(x, y) {
    if(x !== y) {
      throw new Error()
    }
}

// qall lets us not care whether `hashPass` and `checkHashInDB` are
// sync or async
qall(assertEq,
  hashPass(pass)
  checkHashInDB(user)
  )
  .then(function () {
    console.log('ok!')
  }, function () {
    console.log('invalid user or pass')
  })

// with `await`, we can curry the function argument of `qall`
var assertEqAsync = qall.await(assertEq)

assertEqAsync(hashPass(pass), checkHashInDB(user))
  .then(function () {
    console.log('ok!')
  }, function () {
    console.log('invalid user or pass')
  })


qall.join(a, b, c).then(function () {
  // a b and c are just side effects
  // here we just want to continue once they're resolved
})

qall.spread([a, b, c], function (a, b, c) {
  // some fn
})
.then(foo)

api

qall : (fn: Function, ...args: Promise|Any) => Promise resolved with the return value of fn

qall.await : (fn: Function<T>) => Function<Promise<T>> Wraps a fn to let any of its args be a promise. That is, it curries qall with the fn parameter.

qall.join : (...Promise || Array<Promise>) => Promise joins multiple threads of execution and returns a promise

qall.spread : (Array<Promise>, Function) => Promise Waits for all of the promises in an array to be fulfilled and applies the resolved values to a function. Returns a promise for this value.

combinators

qall includes boolean logic combinators which operate on promises:

qall.some : (...terms : Promise<Boolean>) => Promise<Boolean>

qall.every : (...terms : Promise<Boolean>) => Promise<Boolean>

qall.not : (term : Promise<Boolean>) => Promise<Boolean>

For explicit ordering control, for use with Lazy Promises:

qall.someSerial : (...terms : Promise<Boolean>) => Promise<Boolean>

qall.everySerial : (...terms : Promise<Boolean>) => Promise<Boolean>

Array utils

qall.map : (Array<T>|Promise<Array<T>>, (T)=>T2|(T)=>Promise<T2>) => Promise<Array<T2>>

qall.filter : (Array<T>|Promise<Array<T>>, (T)=>Boolean|(T)=>Promise<Boolean>) => Promise<Array<T>>

installation

$ npm install qall

running the tests

From package root:

$ npm install
$ npm test

about the name

Although similar in name to Q.all, the behavior is actually more similar to Q.spread but with a more functionally-inspired API. It should be pronounced like "call".

Lamentably, Promises/A+ doesn't conform to Fantasy Land monads, so this implementation is necessary, rather than a generic liftN.

contributors

license

MIT. (c) MMXIII jden [email protected]. See LICENSE.md