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

node-flo

v0.0.1

Published

Control flow library for nodejs and the browser

Downloads

3

Readme

#flo

###flo.parallel Run several async tasks in paralell and execute a callback when everyone of them is finished. The callback recieves a results array or object depending on the tasks collection type. Returns a promise object that is either failed if a callback receives error, or fulfilled if all passes. Se /classes/Promise docs for reference.

flo.
  parallel([
    function(callback) {
      callback(null, "foo") //when some async task is finished
    },
    function(callback) {
      callback(null, "bar") //when some async task is finished
    },
    function(callback) {
      callback(null, "lol") //when some async task is finished
    }
  ])
  .then(
    function(results) {
      results[0] == "foo" // TRUE
      results[1] == "bar" // TRUE
      results[2] == "lol" // TRUE
    }, 
    function(err) { 
      /* this wont get called since all callbacks got null as error param */
    })

Or passing an object as tasks collection:

flo.
  parallel({
    foo: function(callback) {
      callback(null, "bar") //when some async task is finished
    },
    lawl: function(callback) {
      callback(null, "lol") //when some async task is finished
    },
    lorem: function(callback) {
      callback(null, "lipsum") //when some async task is finished
    }
  })
  .then(
    function(results) {
      results['foo']    == "bar"    // TRUE
      results['lawl']   == "lol"    // TRUE
      results['lorem']  == "lipsum" // TRUE
    }, 
    function(err) { 
      /* this wont get called since all callbacks got null as error param */
    })

###flo.series Runs a set of tasks in series/sequence. Next task wont execute until current task callbacks without error. Largely the same as paralell but in series.

flo
  .series([
    function(callback) {
      setTimeout(function() {
        callback(null, 1)
      },100)
    },
    function(callback) {
      setTimeout(function() {
        callback(null, 2)
      },300)
    },
    function(callback) {
      setTimeout(function() {
        callback(null, 3)
      },200)
    }
  ])
  .then(
    function(results) {
      results[0] == 1 // TRUE
      results[1] == 2 // TRUE
      results[2] == 3 // TRUE
    }, 
    function(error) {
      /* this wont get called since all callbacks got null as error param */
    })

###flo.pipeline Runs a set of tasks in series like async.series. But passes arguments received by callback on to the next task.

flo
  .pipeline([
    function(pipe) {
      User.getById(1, pipe)
    },
    function(user, pipe) {
      user.getSubusers(function(err, subusers) {
        if(err) pipe(err)
        else {
          user.subUsers.add(subusers)
          pipe(null, user)
        }
      })
    },
    function(user, pipe) {
      user.getPosts(function(err, posts) {
        if(err) pipe(err)
        else {
          user.posts.add(posts)
          pipe(null, user)
        }
      })
    },
  ])
  .then(
    function(user) {
      //Now user instance has loaded subusers and posts.
      user.subUsers.render('listview', '#subusers') //Rendering is beyond scope of this lib
      user.posts.render('listview', '#posts')
    }, 
    function(error) {
      /* this wont get called since all pipe callbacks got null as error param */
    })

##Tests The jasmine test framework is ised to test the code. To run the tests do one of the following:

$ cd flo
$ npm test