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

rygr.async-queue

v1.2.0

Published

Async queue mechanism

Downloads

22

Readme

Async Queue

asyncQueue = require 'rygr.async-queue'

Async queue allows you to assemble a series of asynchronous methods to be run in a sequence. This is inspired by Express' middleware feature.

Require

asyncQueue = require 'rygr.async-queue'

or, in JavaScript

asyncQueue = require('rygr.async-queue')

Dependencies

  • For the browser build, async queue depends on jQuery
  • For the node build, async queue depends on q

These dependency differences are denoted in the bower.json and package.json files.

Arguments

Async queue takes three arguments:

  • Args Array|null (required) An array of arguments to be passed to each method in the queue
  • Queue Array* (required) An array of functions to be called in sequence. Each function will receive the arguments passed in and an extra next function to trigger the next function in the queue (required). An error function can be included and is expected to take an extra argument.
  • Done Function (optional) A callback function to be executed when the sequence completes or is short-circuited because of an error. It will receive an error as it's first argument if one occured, or null otherwise.

Useage

asyncQueue = require 'rygr.async-queue'

first = (name, next) ->
  console.log "#{ name }: first!"
  next()

# Throwing an error (or calling next with an error) will cause the queue to skip
# to the error function or skip to call done if none is provided
second = (name, next) ->
  throw new Error 'Uhoh!'

# This function will be skipped since second threw an error
third = (name, next) ->
  console.log "#{ name }: third!"

# The queue will know this is an error method since it takes an extra argument
errorHandler = (error, name, next) ->
  console.log error.message
  next error

# This function will be called last after all the queue has been exhausted
done = (error) ->
  console.log if error then  "Something went wrong." else "Success!"

# Call asyncQueue with the args, function queue, and done function
asyncQueue(['Test'], [
  first
  second
  third
  errorHandler
], done)

# Output:
# Test: first!
# Uhoh!
# Something went wrong.

Development

# From the project's dir
npm install && bower install

Build tool

This project uses Gulp.js for it's build tool

To build:

gulp build

To run tests:

gulp test

To build, run tests, and watch for changes:

gulp