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

tasker-man

v2.0.2

Published

A simple task manager application

Downloads

13

Readme

Tasker Man(ager)

NPM version Downloads License

PM

A powerful and simple task manager.

Note: The old methods of TaskerMan are deprecated and I strongly recommend to use the new one implementation.

Summary

General

Documentation

Installation

You can install using npm or yarn.

npm

npm install tasker-man

yarn

yarn add tasker-man

Usage

const { TaskManager, createTask } = require('tasker-man');

const uniqueTask = createTask(() => console.log("I'll execute once!"));

const repetitiveTask = createTask(() => console.log("I'll execute a few times before stop"), {
  repeat: 5,
  interval: '1s',
  name: '5 times task',
});

const endlessTask = createTask(() => console.log("I'll execute until somebody stop me"), {
  repeat: 'endlessly',
  interval: '10s',
  name: 'endlessly task',
});

// Creates the TaskManager with some tasks
const myManager = createTaskManager(uniqueTask, repetitiveTask);

// You can add some tasks to an already create TaskManager with `append`
myManager.append(endlessTask);

// You can execute a single task by its id
myManager.start(myManager);

Documentation

TaskManager

Main class of application that contains all functions and integrations needed to append, run, stop and pop Tasks.

OBS: TaskerMan is an instance of TaskManager. ##deprecated##

createTaskManager()

Create a new instance of TaskManager.

...
const manager = createTaskManager(task1, task2, task3);

activeTasks()

Return all active Tasks of Task Manager.

const manager = createTaskManager();
const activeTasks = manager.activeTasks();

- returns -

| Type | Description | | :-------- | :------------ | | Task [] | Active Tasks. |


inactiveTasks()

Return all inactive Tasks of Task Manager.

const tasksID = manager.getIdsByName('ExampleTask');
manager.remove(TasksID[0]);

- returns -

| Type | Description | | :-------- | :-------------- | | Task [] | Inactive Tasks. |

append()

Push a task on TaskManager. Example:

...
const manager = createTaskManager();

const task = createTask(taskCallback, taskOptions);
manager.append(task);

| Parameter | Type | Required | Description | | :-------- | :----- | :------- | :--------------- | | task | Task | Yes | A Task Instance. |


remove()

Delete a Task from Task Manager. Example:

...
manager.remove(0);

| Parameter | Type | Required | Description | | :-------- | :------- | :------- | :----------------------- | | id | number | Yes | Task ID on Task Manager. |

OBS: Task ID Can be got by using 'getIdsByName( )' method!


getIdsByName()

Get Tasks IDs on Task Manager using a given name. Example:

const manager = createTaskManager(task1, task2, task3);
const tasksID = manager.getIdsByName('ExampleTask');

manager.remove(tasksID[0]);

| Parameter | Type | Required | Description | | :-------- | :------- | :------- | :------------------------- | | name | string | Yes | Task name on Task Manager. |


start()

Start a Task on Task Manager. Example:

...
const tasksIDs = manager.getIDsByName("ExampleTask");

manager.start(tasksIDs[0]);

| Parameter | Type | Required | Description | | :-------- | :------- | :------- | :----------------------- | | id | number | Yes | Task ID on Task Manager. |

OBS: Task ID Can be got by using 'getIDsByName( )' method!


abort()

Abort a Task from Task Manager. Example:

const tasksIDs = manager.getIDsByName('ExampleTask');

manager.abort(tasksIDs[0]);

| Parameter | Type | Required | Description | | :-------- | :------- | :------- | :----------------------- | | id | number | Yes | Task ID on Task Manager. |

OBS: Task ID Can be got by using 'getIDsByName( )' method!

Tasks

A Task is a object that execute a callback in selected time, with some parameters like delay and repeat.

createTask()

Create a Task on Task Manager.

function taskCallback() {
  console.log('Hello TaskerMan!');
}
const taskOptions = {
  repeat: 'endlessly',
  interval: '2s',
};
const task = createTask(taskCallback, taskOptions);

| Parameter | Type | Required | Description | | :------------ | :------------ | :------- | :----------------------------------- | | callback | function | Yes | Function will be executed by task. | | taskOptions | TaskOptions | No | Object that contain Task parameters. |

- TaskOptions -

| Parameter | Type | Description | | :--------- | :------------------------ | :----------------------------------------------------------------------------- | | name | string | Recommended. Name used to identify a Task on Task Manager. | | repeat | number or "endlessly" | Times task will repeat. If "endlessly", TaskManager will run the task forever. | | delay | number or string | Time task will take to run for the first time. Follow SST Rule. | | interval | number or string | Time task will take to repeat. Follow SST Rule. |

Using Data in Tasks

You can use a data arg in your tasks and modify as you wish in any time to turn Tasks more dynamic.

// just add the arg data in your callback function and use it as you wish
function taskCallback(data) {
  console.log(`Hello, ${data.name}`);
}

// you can define data in task options passed
const taskOptions = {
  repeat: 'endlessly',
  interval: '2s',
  data: {
    name: "Jhon",
    age: 23
  }
};

const task = createTask(taskCallback, taskOptions);

// if you execute this task you will get
// E.g.: Hello, Jhon

...

// and we can update the data of the task at any given time...
task.data.name = "Ana";
task.data.age = 21

// ...then, next time the callback is called, the data will be already updated
// E.g.: Hello, Ana

Typing Data

// in typescript you can define the type expected of your data
interface IData {
  name: string;
  age: number;
}

// as in javascript, just add the arg data in your task callback and define the type
function taskCallback(data: IData) {
  console.log(`Hello, ${data.name}`);
}

// you can pass to the TaskOptions to ensure the data type initializer
const taskOptions: TaskOptions<IData> = {
  repeat: 'endlessly',
  interval: '2s',
  data: {
    name: 'Jhon',
    age: 23,
  },
};

const task = createTask<IData>(taskCallback, taskOptions);

SST

SST or Simple Sequential Time is a time set rule created to supply big time intervals in a simple and intuitive way.

Format

SST use a "-yy -mm -dd -h -m -s" format.

| Symbol | Reference | | :----- | :-------- | | yy | Year | | mm | Month | | dd | Day | | h | Hour | | m | Minute | | s | Second |


Usage

You can use SST with any time you need, since you put the time symbols in order year -> month -> day -> hour -> minute -> second.

Example:

1yy 2mm 5dd 3h 45m 10s

This mean the time interval will be set to 1 year, 2 months, 5 days, 3 hours, 45 minutes and 10 seconds.

You also can skip some symbol and will still work since you keep the order.

Example:

3dd 30m

This mean the time interval will be set to 3 days and 30 minutes.