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

weachy

v1.0.1

Published

a tiny (17 lines of code) async waterfall module

Downloads

3

Readme

weachy

A tiny (17 lines of code) async waterfall implementation that supports CommonJS, AMD, and VanillaJS. The minified file weachy.min.js is just 355 bytes.

build status

Install

npm

npm install weachy

bower

bower install weachy

Usage

waterfall(array, callback, context)

Arguments

  • array - An array of functions that take a callback(err, result1, result2, ...) as the last argument. The arguments preceeding the callback are the results of the previous function in the array.
  • callback(err, result1, result2, ..., resultn) - The callback that is called when all functions in the array are finished or an error occurs.
  • context (optional) - The context to be used when calling each function in the array.

Examples

Browser (No module loader)

<script src="/js/weachy.js"></script>
<script>
  // waterfall is a global bound to the window object now
  waterfall([
    function(next) {
      done(null, 1, 2, 3);
    },
    function(num1, num2, num3, next) {
      done(null, num1 + num2, num3);
    }
  ], function(err, sum, num3) {
    console.log(sum);
    // 3
    console.log(num3);
    // 3
  });
</script>

Node.js

var waterfall = require('weachy');
var jsdom = require('jsdom');
var fs = require('fs');

var url = process.argv[2];

waterfall([
  function(next) {
    fs.readFile('./jquery.js', 'utf-8', next);
  },
  function(jquery, next) {
    jsdom.env({
      url: url,
      src: [jquery],
      done: next
    });
  },
  function(window, next) {
    // Get a reference to jQuery
    var $ = window.$;
    var images = $('img').map(function() {
      return this.src;
    });
    // Convert a NodeList to an array
    next(null, Array.prototype.slice.call(images));
  }
], function(err, imageUrls) {
  if (err) {
    console.error(err);
    return process.exit(1);
  }
  var filename = 'images-' + Date.now() + '.txt';
  fs.writeFile(filename, imageUrls.join('\n'), function(err) {
    if (err) console.error(err);
    else console.log(filename);
    // Type coercion to go undefined|Error -> bool -> number
    process.exit(+!!err);    
  });
});