DEV Community

Rap2h
Rap2h

Posted on

3 1

Introducing taskz

Taskz is a library for Node.js, a simple sequential and parallel task list runner for terminal.

Getting started

Install it via npm i taskz. Create your task sequence in any script file then run it.

const taskz = require("taskz");

taskz([
  {
    text: "first task - sleeps for 200ms",
    task: async () => await new Promise(resolve => setTimeout(resolve, 200));
  },
  {
    text: "this task will fail",
    task: async () => {
      throw new Error("this task failed");
    }
  }
]).run();
Enter fullscreen mode Exit fullscreen mode

So in other word, you have to create a array of tasks:

const myTasks = [
  { text: "task 1", task: () => { /* ... */ } },
  { text: "task 2", task: () => { /* ... */ } }
];
Enter fullscreen mode Exit fullscreen mode

Then pass it to the taskz function and call run to start the process:

taskz(myTasks).run();
Enter fullscreen mode Exit fullscreen mode

You can also run task in parallel:

taskz(myTasks, { parallel: true }).run();
Enter fullscreen mode Exit fullscreen mode

Other features: subtasks, stop on fail, pass context from task to task,
change text within a task during execution.

Have fun with it: link to github repository

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay