New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ninmu

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ninmu

A simple environment-agnostic library for managing async tasks

latest
Source
npmnpm
Version
0.0.0-alpha.4
Version published
Maintainers
1
Created
Source

Ninmu

A simple environment-agnostic library for managing async tasks. Ninmu (任務) is the Japanese word for "task".

Highlights:

  • Easy to integrate with any application
  • Minimal bundle size (down to 2kb after gzipped)
  • Self-contained package without dependencies
  • Flexible and extensible

Getting Started

Install Ninmu using npm:

npm i ninmu

Then, create an engine:

import { createEngine } from 'ninmu';

const engine = createEngine();

And create your tasks:

const greetingTask = engine.createTask({
  name: 'greeting',
  // Both sync and async tasks are supported.
  async execute() {
    console.log('Hello, world!');
  }
});

const farewellTask = engine.createTask({
  name: 'farewell',
  // You can specify some tasks as dependencies.
  dependencies: [greetingTask],
  execute() {
    console.log('Bye!');
  }
});

Finally, start the engine:

engine.start();

Under the hood

Ninmu has two primary types: Task and Engine. Task represents an individual unit of work, while Engine manages the execution of these tasks. Task can have dependencies, which are the tasks that must be completed before the task itself can be executed. In the above example, farewellTask depends on greetingTask, meaning farewellTask will only be executed after greetingTask has finished.

Engine schedules the execution of tasks for you. So you can just create tasks and let the engine handle the rest.

Tasks are executed in parallel by default, but you can utilize dependencies to implement sequential execution — i.e., make every task depend on the last one. There are not many restrictions or preset behaviors, which allows you to use it flexibly to fit your specific needs.

Advanced Usage

Observe task status

Task and Engine exposes various events that you can listen to. For example, do something when a task is failed:

task.onFail((err) => {
  console.log('Task failed:', err);
});

You can also observe all tasks' status via Engine.onUpdate:

engine.onUpdate((task) => {
  console.log(`Task "${task.options.name}" updated`);
});

Pass arguments

Task's execute method doesn't accept any arguments. If your task needs some arguments, you can capture them in execute closure when creating the task:

function createGreetingTask(engine, person) {
  return engine.createTask({
    name: 'greeting',
    async execute() {
      console.log(`Hello, ${person}!`);
    }
  });
}

More

See tests or type definitions for more.

License

Licensed under MIT License, see LICENSE for more information.

FAQs

Package last updated on 20 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts