https://github.com/skyfe79/jobpipeline
A simple job pipeline package for processing tasks in sequence.
https://github.com/skyfe79/jobpipeline
Last synced: about 1 year ago
JSON representation
A simple job pipeline package for processing tasks in sequence.
- Host: GitHub
- URL: https://github.com/skyfe79/jobpipeline
- Owner: skyfe79
- Created: 2023-03-24T10:50:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-24T11:00:59.000Z (about 3 years ago)
- Last Synced: 2024-04-26T03:02:31.862Z (about 2 years ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/jobpipeline
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JobPipeline
A simple job pipeline package for processing tasks in sequence.
## Installation
```bash
npm install jobpipeline
```
## Usage
First, import the necessary classes:
```ts
import { Pipeline } from "jobpipeline";
import { AddJob } from "jobpipeline/dist/exampleJobs/AddJob";
import { MulJob } from "jobpipeline/dist/exampleJobs/MulJob";
```
Next, create a new Pipeline instance and add jobs to it:
```ts
const pipeline = new Pipeline();
const addJob = new AddJob();
const mulJob = new MulJob();
pipeline.addJob(addJob);
pipeline.addJob(mulJob);
```
Finally, run the pipeline:
```ts
const input = 5;
pipeline
.run(input)
.then((result) => console.log(`Result: ${result}`))
.catch((error) => console.error(`Error: ${error.message}`));
```
This will run the AddJob and MulJob in sequence, adding 1 to the input and then multiplying the result by 2.
## Creating Custom Jobs
To create a custom job, implement the Job interface:
```ts
import { Job } from "jobpipeline";
class CustomJob implements Job {
name = "CustomJob";
async run(input: InputType): Promise {
// Your custom processing logic here
}
}
```
Replace InputType and OutputType with the appropriate types for your job.
## License
This package is licensed under the MIT License.