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

promise-task-runner

v0.0.2

Published

- This readme covers a few basics. For anything more, please see [the wiki](https://github.com/olsonpm/promise-task-runner/wiki). I have spent a lot of effort into making the wiki useful, so please give it a shot. - To avoid confusion, the abbreviation

Downloads

3

Readme

promise-task-runner

  • This readme covers a few basics. For anything more, please see the wiki. I have spent a lot of effort into making the wiki useful, so please give it a shot.
  • To avoid confusion, the abbreviation 'ptr' is for promise-task-runner.

First of all, why does promise-task-runner exist?

Because I liked the concept of a streaming build-system as made popular by Gulp, but I didn't like its task management library. I thought dependencies would be best handled via promises, I thought command-line option support should be built-in, and I thought tasks should be able to pass results down to other dependent tasks.

Why would I want to use this tool?

You'll find this tool useful if you're more comfortable managing task dependencies via promises, or want tasks to pass results down to dependent tasks. I also hope you find ptr easy to pick up, as I've spent a lot of effort organizing the documentation for ease of use. There are plenty of examples and an explicit API.

What does a task look like?

You declare a task using the PromiseTask object

// tasks/scripts.js
var ptr = require('promise-task-runner');
var PromiseTask = ptr.PromiseTask
var scripts = new PromiseTask()
  .id('scripts')
  .task(function() {
    // task logic
  });

Then add it to a PromiseTaskContainer and export the container

// tasks/scripts.js
...
var PromiseTaskContainer = ptr.PromiseTaskContainer;
var ptc = new PromiseTaskContainer();
ptc.addTask(scripts);
module.exports = ptc;

Now in your root project folder, you can call:

$ ptr run-task scripts
Finished running task 'scripts' in 0.2 seconds

Great, how do I get started?

The wiki should get you on your way

What's with the weird (fluent) api?

You'll notice that instead of passing in constructor function parameters, you pass them in via property functions that act both as getters and setters. You set the property by passing a parameter, and you get the property by calling it with no parameters. Thus, using the task 'scripts' from above:

scripts.id(); // returns 'scripts'
scripts.id('scripts2'); // sets id to 'scripts2' and returns itself, creating a fluent api

scripts
  .id('scripts')
  .task(function() { ... });

It's intuitive and removes ambiguity between what function parameters are, what order they need to be passed, and how optional parameter logic is handled. The API preface gives a little more detail.