{"id":23280977,"url":"https://github.com/nicholaswmin/job-sequencer","last_synced_at":"2026-05-19T14:04:24.688Z","repository":{"id":78088779,"uuid":"99342106","full_name":"nicholaswmin/job-sequencer","owner":"nicholaswmin","description":"Run strictly sequential jobs in Node.js whilst emitting W3C ProgressEvents","archived":false,"fork":false,"pushed_at":"2018-08-12T21:09:06.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-29T08:34:03.118Z","etag":null,"topics":["batch-processing","node-js","w3c-progress-events"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicholaswmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-04T12:46:44.000Z","updated_at":"2023-03-08T02:33:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"99b2b0b8-ea05-45b3-859d-4c1cf1fe8cca","html_url":"https://github.com/nicholaswmin/job-sequencer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nicholaswmin/job-sequencer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fjob-sequencer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fjob-sequencer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fjob-sequencer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fjob-sequencer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicholaswmin","download_url":"https://codeload.github.com/nicholaswmin/job-sequencer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicholaswmin%2Fjob-sequencer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33219388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:54:09.561Z","status":"ssl_error","status_checked_at":"2026-05-19T07:54:08.508Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batch-processing","node-js","w3c-progress-events"],"created_at":"2024-12-19T23:39:48.927Z","updated_at":"2026-05-19T14:04:24.642Z","avatar_url":"https://github.com/nicholaswmin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Job sequencer\n\n[![Build Status](https://travis-ci.org/nicholaswmin/job-sequencer.svg?branch=master)](https://travis-ci.org/nicholaswmin/job-sequencer)\n\nRun long-running jobs, one at a time, whilst emitting W3C ProgressEvents\n\n## Basic Usage\n\nJust inherit from `JobSequencer`\n\n```javascript\n\nconst JobSequencer = require('job-sequencer')\n\nclass LongRunningJobManager extends JobSequencer {\n  constructor() {\n    super()\n  }\n\n  async batchProcessFoo() {\n    let batchJobFoo\n\n    try {\n      // Create a job with name 'batch-process-foo' that will tick\n      // `job.progress()` 5 times\n      batchJobFoo = this.createJob('batch-process-foo', 5);\n      batchJobFoo.start()\n      batchJobFoo.progress()\n      batchJobFoo.progress()\n      batchJobFoo.progress()\n      batchJobFoo.progress()\n      batchJobFoo.progress()\n      batchJobFoo.success({ foo: 'bar' })  \n    } catch (err) {\n      job.error(err)\n    }\n  }\n}\n\nconst batchProcessor = new LongRunningJobManager()\n\nbatchProcessor.on('status', status =\u003e {\n  switch (status.type) {\n    case 'loadstart':\n      console.log('started')\n      break;\n    case 'progress':\n      console.log(status.progress) // `{ total: 5, loaded: 2 }`.. etc\n      break;\n    case 'load':\n      console.log(status.payload) // `{ foo: bar }`\n      break;\n    case 'error':\n      console.log(status.payload) // logs any potential error\n      break;\n    default:\n      // do nothing\n  }\n})\n\nbatchProcessor.batchProcessFoo()\n```\n\n## Sequential Running\n\nYou can only run *one job at a time*. If any of the following events are\ncalled:\n\n- `job.success()`\n- `job.error()`\n- `job.abort()`\n- `job.stop()`\n\nthe `Job` is considered finished and it's ejected, thus allowing\nother `Job`'s with the same name to run.\n\nAttempting to run another `Job` with the same name if the aforementioned methods\nhave not been called on `Job` will result in an `Exception`\n\n\n## Events Emitted\n\nAll events map to [W3C Progress Events][1]\n\n| Method           | W3C ProgressEvent emitted |\n|------------------|---------------------------|\n| `job.start()`    | `loadstart`               |\n| `job.progress()` | `progress`                |\n| `job.error()`    | `error`                   |\n| `job.abort()`    | `abort`                   |\n| `job.success()`  | `load`                    |\n| `job.stop()`     | `loadend`                 |\n\n## Tests\n\n```bash\nnpm test\n```\n\n```bash\n\nJob Sequencer\n  ✓ it instantiates\n  when a Job is created\n    ✓ creates a Running Job\n    ✓ returns a Running Job by name if it exists\n    ✓ returns true if a Running Job exists by name\n    ✓ returns a list of all the last statuses emitted by still running, Running Jobs\n    ✓ clears the Running Job if the job has succeeded\n    ✓ clears the Running Job if the job is errored\n    ✓ clears the Running Job if the job is aborted\n    ✓ clears the Running Job if the job is stopped\n  when attempting to create a Job whilst another is running\n    ✓ throws an exception\n    ✓ creates the Job if the Job is done\n    ✓ creates the Job if the Job is errored\n    ✓ creates the Job if the Job is aborted\n    ✓ creates the Job if the Job is stopped\n\nJob Class\n  ✓ instantiates in the correct state\n  ✓ fires a loadstart event when start is called\n  ✓ fires a progress event when progress is called\n  ✓ fires an error event when error is called\n  ✓ fires an abort event when abort is called\n  ✓ fires a load event when success is called\n  ✓ fires a loadend event when stop is called\n  ✓ increments the loaded count by 1 when a progress event is emitted\n  ✓ includes the job name when emitting an event\n  ✓ includes any payload passed as arg. when emitting an event\n  ✓ returns the last emitted status\n\n```\n\n## License\n\n\u003e Copyright 2017 Nicholas Kyriakides\n\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\n\u003e The above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n[1]: https://www.w3.org/TR/progress-events/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaswmin%2Fjob-sequencer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicholaswmin%2Fjob-sequencer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicholaswmin%2Fjob-sequencer/lists"}