Task Conveyor System
tacs is a process management system inside the process (nodejs) to handle the huge amount of requests that need accuracy and slow down separately whatever and every time you do a push it will activate an algorithm ($lab), like a Conveyor System Imagine it yes this you can do that in your project
Installation
npm install tacs
yarn add tacs
Usage
CommonJS
const { Conveyor, getConveyor } = require("tacs");
ES6
import { Conveyor, getConveyor } from "tacs";
Updates
@latest
+ Fix SyntaxError: Private field '#' must be declared in an enclosing class
Example
Go To Documentation
Try
this is a simple example on replit Try it
First Example (Without Key System)
const { Conveyor } = require("tacs");
const tacs = new Conveyor();
tacs.$lab((element, index, remove) => {
//To see how remove works go to the examples (see remove)
if (remove) {
console.log("This Element is Remove:\n", element);
return tacs.next();
}
console.log(element, "My Index is: ", index);
tacs.next().catch((err) => {
console.log(err); //if you Kill the conveyor and you have a next() it will throw an error
});
});
tacs
.push([
{
name: "John",
age: 30,
},
{
name: "Mary",
age: 25,
},
{
name: "Mike",
age: 20,
},
{
name: "Jane",
age: 35,
},
{
name: "Joe",
age: 40,
},
])
.catch((err) => {
console.log(err); //if you Kill the conveyor and you have a push() it will throw an error
});
//Every time you do a push it will activate $lab algorithm
Example (With Key System)
index.js
const { Conveyor, getConveyor } = require("tacs");
const tacs = new Conveyor("employees"); //or getConveyor("employees", true);
tacs.$lab((element, index, remove) => {
//To see how remove works go to the examples (see remove)
if (remove) {
console.log("This Element is Remove:\n", element);
return tacs.next();
}
console.log(element, "My Index is: ", index);
tacs.next().catch((err) => {
console.log(err); //if you Kill the conveyor and you have a next() it will throw an error
});
});
//Every time you do a push it will activate $lab algorithm
another.js
const { getConveyor } = require("tacs");
getConveyor("employees") //if you don't have a conveyor for this key it will throw an error
.push([
{
name: "John",
age: 30,
},
{
name: "Mary",
age: 25,
},
{
name: "Mike",
age: 20,
},
{
name: "Jane",
age: 35,
},
{
name: "Joe",
age: 40,
},
])
.catch((err) => {
console.log(err); //if you Kill the conveyor and you have a push() it will throw an error
});
documentation
Method | Description | explain |
---|---|---|
$lab() | this is $lab function that will be emit when you push element or when you call next | Go to example |
next() | go to next index | Go to example |
push() | push element to the conveyor {element} is an array | Go to example |
sleep() | sleep the conveyor {timeout} milliseconds later after timeout is over it wil be next automatically | Go to example |
on() | The events | Go to example |
kill() | kill the conveyor use this if you use this you can't use next() or any other function | Go to example |
get() | get pushed Data or option or remove or exist | Go to example |
Method
lab
//this is $lab function that will be emit when you push element or when you call next
tacs.$lab((element, index, remove) => {
console.log(element, index, remove);
//To see how remove works go to the examples (see remove)
if (remove) {
console.log("This Element is Remove:\n", element);
tacs.next();
//if you want set timeout for this function include next method in setTimeout function
return;
}
tacs.next();
//if you want set timeout for this function include next method in setTimeout function
});
next
//go to next index
tacs.next();
//if you want set timeout for this function include next method in setTimeout function
push
//push(Your Data)
//if you want to push element to the conveyor use this
// This is an example of pushing element to the conveyor
//Array
tacs.push(["JavaScript", "C", "C++", "C#", "Java", "Python"]);
//Object
tacs.push({
name: "John",
age: 30,
city: "New York",
});
//String or Number or any other type
tacs.push("Arth");
sleep
//sleep the conveyor {timeout} milliseconds later after timeout is over it wil be next automatically
tacs.sleep(1000); //sleep for 1 second
on
//The events
tacs.on("push", (element) => {
console.log(element); //element is an array
});
tacs.on("end", (element) => {
console.log(element); //Array: all the element in the conveyor
});
restart
//if you want to restart the conveyor use this and it will restart from the first index
tacs.on("end", (element) => {
tacs.push(tacs.get().pushed);
});
kill
//kill the conveyor use this if you use this you can't use next() or any other function
tacs.kill();
get
pushed
tacs.get().pushed; //Array: returns an array with the pushed element
option
tacs.get().option; //String: returns the last option
remove
//remove the element from the conveyor and return remove parameter in $lab function
tacs.get(/*<Element>*/).remove(); //No Return: remove element from the array
//Some examples
tacs.get({ name: "Joe", age: 40 }).remove(); //remove element from the array
//or you can use this specitic value
tacs.get({ name: "Joe" }).remove(); //remove element from the array
//String or Number or any other type exmaple for string
tacs.get("JavaScript").remove(); //remove element from the array
exist
tacs.get(/*<Element>*/).exist(); //Boolean: returns true if the element exist in the array
//Some examples
tacs.get({ name: "Joe", age: 40 }).exist(); //returns true if the element exist in the array
//or you can use this specitic value
tacs.get({ name: "Joe" }).exist(); //returns true if the element exist in the array
//String or Number or any other type exmaple for string
tacs.get("JavaScript").exist(); //returns true if the element exist in the array