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

promiserunner

v0.1.3

Published

A simple promisifying utility to make functions run in an asynchronous fashion.

Downloads

3

Readme

Promise Runner:

A simple promisifying utility to make functions run in an asynchronous fashion.

Simply use the run() method start the promise chain and put the followed functions in order inside a .then() or add all the functions to a queue and when ever you want the queue to be executed run the .runQueue() method.

Usage:

After installing the package either globally or locally, import or require in the javascript source you need to use in and create an instence. to install locally:

npm install promiserunner # installs locally

Or to install globally make sure you have the correct privilidges,

npm install -g promiserunner # installs globally
  var PromiseRunner = require('promiserunner');
  var chain=new PrimiseRunner();

There are two ways to By using the add method queue up the functions to be run asynchronously followed by the parameters the function accepts in an array in the correct order.

chain.add(f1,[1]).add(f2,[2,3]).add(f3,[5,3,5,9]).add(f3).add(f2,[100,200]).add(f5);

Keep in mind to add chain.resolve() or chain.reject() to the place you want the function to continue to the next one in line. The body of function f1 would look something like this:

var f1=function(input){
    setTimeout(function(){
     	console.log(1,input);
 	    chain.resolve(); //this is where we go to the next function
    },100);
};

when ever there is need for the queue to run use the runQueue() method to start the asynchronouse run process.

chain.runQueue();

Another method to run wrap the functions in a promise would be to use the .run() method directly:

p.run(f2)
 .then(p.run(function({
		 f1('hello');}))
 .then(p.run(f2))
 .then(p.run(f1));

Functions wrapped in a promise:

  • somewhere in the body of the function a resolve('someMessage') must be provided so that the chain doesn't break and the promise and resolves to the next function. You may also put a reject and if the function fails call .reject().
var i=1;
var f1=function one(resolve,i){ //resolve as the first parameter
	if(i==1){
		console.log('one',i);
	    chain.resolve('done'); //resolve here
    }else
    {
	    chain.reject('fail'); //rejects here
    }
};

Version

0.1.2

Todos

  • create tests
  • add stop and pause functionalities to queue runner
  • Add Code Comments

Links