Skip to content

Instantly share code, notes, and snippets.

@markotom
Created August 13, 2021 02:35
Show Gist options
  • Save markotom/0f1411cfe93e28610263b6013d587df8 to your computer and use it in GitHub Desktop.
Save markotom/0f1411cfe93e28610263b6013d587df8 to your computer and use it in GitHub Desktop.
Draft for a possible JS library for tasking/scripting

Draft for a possible JS library for tasking/scripting

For a simple task:

const task = new Task.Simple();

task.setHandler((ctx) => {
  // doing something
});

task.run();

For a task executed in batch using a read stream (less opinionated):

const task = new Task.Batch({ size: 10 });

task.setHandler((ctx) => {
  // doing something
});

task.readFrom(() => {}); // should return a read buffer

task.run();

For a task executed in batch with specific streaming process:

SQL:

const task = new Task.Batch({ size: 10 });

task.setHandler((ctx) => {
  // doing something
});

task.readFromSql('SELECT * FROM table'); // invoke on the base of "task.readFrom"

task.run();

CSV:

const task = new Task.Batch({ size: 10 });

task.setHandler((ctx) => {
  // doing something
});

task.readFromCsv('./records.csv'); // invoke on the base of "task.readFrom"

task.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment