https://github.com/palcarazm/batchjs
Dependencies free batch processing framework for NodeJS based on streams.
https://github.com/palcarazm/batchjs
batch-processing framework nodejs streams-batch-processing-framework
Last synced: about 1 year ago
JSON representation
Dependencies free batch processing framework for NodeJS based on streams.
- Host: GitHub
- URL: https://github.com/palcarazm/batchjs
- Owner: palcarazm
- License: mit
- Created: 2024-07-20T13:44:43.000Z (over 1 year ago)
- Default Branch: version/v1
- Last Pushed: 2025-02-24T02:12:23.000Z (about 1 year ago)
- Last Synced: 2025-03-09T19:37:04.325Z (about 1 year ago)
- Topics: batch-processing, framework, nodejs, streams-batch-processing-framework
- Language: TypeScript
- Homepage:
- Size: 199 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://github.com/palcarazm/batchjs/blob/version/v1/LICENSE)
[](https://github.com/palcarazm/batchjs/releases)
[](https://www.npmjs.com/package/batchjs)
[](https://github.com/palcarazm/batchjs/actions/workflows/ci-workflow.yml)
[](https://coveralls.io/github/palcarazm/batchjs)
[](https://github.com/sponsors/palcarazm)
# BatchJS
Dependencies free batch processing framework for NodeJS based on streams.
---
- [BatchJS](#batchjs)
- [Download](#download)
- [NPM](#npm)
- [Yarn](#yarn)
- [Usage](#usage)
- [Documentation](#documentation)
- [Collaborators welcome!](#collaborators-welcome)
---
# Download
[](https://github.com/palcarazm/batchjs/releases)
## NPM
[](https://www.npmjs.com/package/batchjs)
```ksh
npm install batchjs
```
## Yarn
```ksh
yarn add batchjs
```
# Usage
```typescript
import { Job, Step } from "batchjs";
// Implement a step
class StepImplementation extends Step {
// Set a name to the step
constructor(name: string = "MockPassingStep") {
super(name);
}
// Implement the reader to load step data source
protected _reader() {
return new Readable({
objectMode: true,
read() {
this.push("data");
this.push(null);
},
});
}
// Implement the processors to transform data sequently using our streams or your own streams
protected _processors() {
const opts: TransformOptions = {
objectMode: true,
transform(
chunk: unknown,
encoding: BufferEncoding,
callback: TransformCallback
) {
this.push(chunk);
callback();
},
};
return [new Transform(opts), new Transform(opts)];
}
// Implement the write to stock final step data
protected _writer() {
return new Writable({
objectMode: true,
write(
chunk: unknown,
encoding: BufferEncoding,
callback: TransformCallback
) {
callback();
},
});
}
}
// Implement a Job
class JobImplementation extends Job {
// Implement to set the steps to be sequently executed.
protected _steps() {
return [new StepImplementation(), new StepImplementation()];
}
}
// Instance the Job
const job = new JobImplementation("My job");
// Set events listener
job.on("stepStart", (step: step) => {
console.log(`Starting step ${step.name}`);
});
// Launch the job
job
.run()
.then(() => {
console.log("Job completed successfully");
})
.catch((error) => {
console.log("Job completed with errors");
});
```
# Documentation
- [Core API](./docs/common-api.md)
- [Stream API](./docs/streams-api.md)
# Collaborators welcome!
- ¿Do you like the project? Give us a :star: in [GitHub](https://github.com/palcarazm/batchjs).
- :sos: ¿Do you need some help? Open a discussion in [GitHub help wanted](https://github.com/palcarazm/batchjs/discussions/new?category=q-a)
- :bug: ¿Do you find a bug? Open a issue in [GitHub bug report](https://github.com/palcarazm/batchjs/issues/new?assignees=&labels=bug&projects=&template=01-BUG_REPORT.yml)
- :bulb: ¿Do you have a great idea? Open a issue in [GitHub feature request](https://github.com/palcarazm/batchjs/issues/new?assignees=&labels=feature&projects=&template=02-FEATURE_REQUEST.yml)
- :computer: ¿Do you know how to fix a bug? Open a pull request in [GitHub pull request](https://github.com/palcarazm/batchjs/compare).
- ¿Do you know a security issue? Take a read to our [security strategy](https://github.com/palcarazm/batchjs/blob/version/v1/SECURITY.md).
[](https://github.com/palcarazm/batchjs/graphs/contributors)
[Subscribe our code of conduct](https://github.com/palcarazm/batchjs/blob/version/v1/CODE_OF_CONDUCT.md) and follow the [Contribution Guidelines](https://github.com/palcarazm/batchjs/blob/version/v1/CONTRIBUTING.md).