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

fnqueue

v2.0.2

Published

A powerful utility for function chaining

Downloads

40

Readme

node-fnqueue project status

A powerful utility for function chaining (inspired by async).

Engine

  • nodejs v0.4.12+ (tested with v0.6.x)

Installation with npm

$ npm install fnqueue

Syntax

new FnQueue(functionsList[, callback, concurrencyLevel, isStopped]);

##Parameters

  1. functionsList (Object) a list of Functions. Each function can declare implicit dependencies as arguments and assume you provide a single callback as the last argument.
  2. callback (Function(err, data)) the complete callback in the conventional form of function (err, data) { ... }
  3. concurrencyLevel (Number/String: defaults to 'auto') the concurrency level of the chain execution, can be 'auto' or N* = { 1, 2, ... }
  4. isStopped (Boolean: defaults to false) if true you must call the start method in order to execute the function list.

##Methods

  • start: will start the execution, used in combination with isStopped = true constructor parameter

##Attributes

  • isVerbose (Boolean): will change the instance verbose mode

##Notes

FnQueue runs a list of functions, each passing their results to the dependent function in the list. However, if any of the functions pass an error to the callback, the next function is not executed and the main callback is immediately called with the error.

Each dependency/argument must be named with the label of the dependent function in the functionsList (the first constructor argument). Each function with a dependency will be called with the result of the dependent function as expected. (Introspection by introspect)

The global callback is called once, on the first error or at the end of the execution. A data object will be provided with the indexed result of the functions.

FnQueue magically resolves all dependencies and executes functions in the right order with the provided concurrency level.

##Example

var FnQueue = require('fnqueue');

or for a verbose mode:

var FnQueue = require('fnqueue').verbose();

Example:

new FnQueue({
  // this will wait for 'processSomething' and 'searchSomething' and will be called with the respective results
  funnyStuff: function (processSomething, searchSomething, callback) {
    // do something silly
    callback(null, 'ciao!');
  },
  // this will be called instantly
  searchSomething: function (callback) {
    // do something with database
    callback(err, results);
  },
  // this will wait 'searchSomething'
  update: function (searchSomething, callback) {
    // change values inside results and save to db
    callback(err); // no needs to return values
  },
  // this will wait 'searchSomething'
  processSomething: function (searchSomething, callback) {
    var start = new Date().getTime();
    // do something slow
    var elapsedTime = new Date().getTime() - start;
    callback(err, elapsedTime);
  }]
}, function (err, data) {

  if (err) {
    throw err;
  }

  console.log(data.searchSomething);  // results
  console.log(data.update);           // undefined
  console.log(data.processSomething); // elapsedTime
  console.log(data.funnyStuff);       // 'ciao!'
}, 1);

Test

Tests depends on http://vowsjs.org/ then

npm install -g vows
npm install
npm test

tests

License

This software is released under the MIT license cited below.

Copyright (c) 2010 Kilian Ciuffolo, [email protected]. All Rights Reserved.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.