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

@dataparty/tasker

v0.0.3

Published

dependency solving task runner

Downloads

5

Readme

Tasker

stablelicense

Tasker is a parallel task runner with dependency resolution and results collection.

Design

Tasker provides a Runner class which manages depedencies, tasks and results. The runner class utilizes the dependency-solver npm package. When possible upto Runner.parallel foreground tasks will be run at the same time. When background tasks are added to the Runner they are started immeditaly and do not count against the parallel limit.

Tasks are added to the Runner by calling Runner.addTask(task). Every Runner.planningIntervalMs added tasks have their dependencies reveiwed and the schedule is updated. Tasks are scheduled in order of:

  1. Order of calls to Runner.addTask(task)
  2. Task with no dependencies
  3. Task with depenedencies, in order after solving usage graph

As tasks are completed they can resolve with a result (or not). Any task that has defined dependencies will receive a reference to the task they depend upon in the depends argument passed to Task.exec({task, depends})

Consumers of the library are expected to extend the Task class to later instantiate and add instances to a runner. Tasks are added by calling Runner.addTask(task).

For more details see documentation:

Foreground Tasks

By default tasks are in the foreground. Tasks can be defined either with a function or by subclassing. See a complete tutorial.

Define task using function

let sleepThirty = async ()=>{
  return new Promise((resolve,reject)=>{
    setTimeout(resolve, 30*1000)
  })
}

let myTask = Tasker.Task({
  name: 'sleep-30',
  exec: sleepThirty
})

runner.addTask(myTask)

Define task with subclass

class SleepTask extends Tasker.Task {
  constructor(durationMs){
    this.duration = durationMs
    this.timeout = null
  }

  async exec(){
    return new Promise((resolve,reject)=>{

        this.timeout = setTimeout(this.onTimeout.bind(this), 30*1000)

      })
    }
  }

  onTimeout(){
    this.timeout = null
    console.log('sleep complete')
  }

  stop(){
    if(this.timeout !== null){
      clearTimeout(this.timeout)
      this.timeout = null
    }
  }
}


let sleepThirty = new SleepTaks(30*1000)

runner.addTask(sleepThirty)
runner.start()

Background Tasks

Background tasks do not count against the parallel task limit. On failure background tasks are restarted immediatly and will be kept running indefinitly. Background tasks only ever stop if they are explicitly cancelled.

How to implement a background task