task-eater
v1.0.4
Published
Control task package with jobs
Downloads
5
Readme
Task Eater
Description
Control task package with jobs
Examples
// Simple job to change string to number
class StringToNumberJob implements IJob<string, number> {
constructor() {}
jobName: string = "StringToNumberJob";
dispatch(input: string): Promise<number> {
return new Promise((res, rej) => {
res(parseInt(input, 10));
});
}
}
// Simple job get string to return same string
class StringJob implements IJob<string, string> {
constructor(private initialValue: string) {}
jobName: string = "StringJob";
dispatch(input: string): Promise<string> {
return new Promise((res, rej) => {
res(input || this.initialValue);
});
}
}
const MyFirstTask = new Task({ name: "MyFirstTask" });
const result = await MyFirstTask.runJobs(
new StringJob("81"),
new StringToNumberJob(),
);
// expected result 81