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

tasking

v0.1.0

Published

Tiny tasking system

Downloads

37

Readme

tasking

Tiny tasking system

var { create, add, run } = require('tasking')

// Create a task system:
var task = create('my-example')

// Add a sync task:
add(task, 'foo', function () {
  // ...
})

// Add an async task:
add(task, 'bar', ['foo'], function (done) {
  something(function (err) {
    if (err) return done(err)
    // ...
    done()
  })
})

// Run tasks:
run(task, 'bar', function (err) {
  if (err) throw err
  // ...
})

Tiny tasking system based on three simple functions: create, add, and run.

Installation

$ npm install --save tasking

Usage

tasking(name)

tasking.create(name)

Create a task system where tasks and other meta info is stored. tasking.create alias useful when destructuring

  • name (String): Name of the system.
var task = tasking('my-build')
// Or:
var task = tasking.create('my-build')

Note: It is nice to name it task when used with add(task, ...) and run(task, ...), but is also referred to as system

tasking.add(system, name, [deps], [fn])

Add task to a system. Each task has a name associated to dependencies and/or a function

  • system (Object): The return system from tasking.create
  • name (String): Name of the task you are creaing
  • deps (Array): Tasks to run before this one starts
  • fn (Function): Function for the task. Sync or async if it has done param
var add = tasking.add

add(task, 'foo', function () {
  // Task to be run
})

add(task, 'bar', ['foo'], function () {
  // ...
})

add(task, 'baz', function (done) {
  setTimeout(function () {
    // ...
    done()
  }, 1000)
})

add(task, 'qux', ['foo', 'bar'])

When ran, the dependencies are run first. Dependencies reference names to other tasks on the same system

If the task's function has a done parameter, it is ran as async, otherwise it is ran as sync

tasking.run(system, name, [done])

Run task in system. Will run specified dependency tasks first, but only once during the whole execution

  • system (Object): The return system from tasking.create
  • name (String|Array): Name or array of names of what you are running
  • done (Function): Callback after task(s) completed. Defaults to throwing error.
run(task, 'foo', function (err) {
  // ...
})

run(task, ['foo', 'bar'], function (err) {
  // ...
})

It is important to know that async tasks are run in parallel, use add + run to create serially running tasks:

add(task, 'foo', function (done) {
  // run a dependency serially:
  run(task, 'bar', function () {
    // ...
    done()
  })
})

Also see async-series

Structure

The system and tasks follow an easy-to-use structure:

// System properties:
system.name
system.tasks

// Get tasks by name:
var foo = system.tasks.foo

// Task properties:
foo.fn
foo.deps
foo.name

License

MIT © Jamen Marz


version travis downloads license support me follow