{"id":17445996,"url":"https://github.com/jamen/tasking","last_synced_at":"2025-04-02T11:22:33.306Z","repository":{"id":65514741,"uuid":"79910528","full_name":"jamen/tasking","owner":"jamen","description":"Tiny tasking system","archived":false,"fork":false,"pushed_at":"2017-01-24T14:13:15.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-26T17:47:23.196Z","etag":null,"topics":[],"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/jamen.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}},"created_at":"2017-01-24T12:42:00.000Z","updated_at":"2023-02-19T08:57:40.000Z","dependencies_parsed_at":"2023-01-26T21:05:13.130Z","dependency_job_id":null,"html_url":"https://github.com/jamen/tasking","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftasking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftasking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftasking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Ftasking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamen","download_url":"https://codeload.github.com/jamen/tasking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246803074,"owners_count":20836485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-17T18:19:56.233Z","updated_at":"2025-04-02T11:22:33.284Z","avatar_url":"https://github.com/jamen.png","language":"JavaScript","funding_links":["https://paypal.me/jamenmarz/5usd"],"categories":[],"sub_categories":[],"readme":"# tasking\n\n\u003e Tiny tasking system\n\n```js\nvar { create, add, run } = require('tasking')\n\n// Create a task system:\nvar task = create('my-example')\n\n// Add a sync task:\nadd(task, 'foo', function () {\n  // ...\n})\n\n// Add an async task:\nadd(task, 'bar', ['foo'], function (done) {\n  something(function (err) {\n    if (err) return done(err)\n    // ...\n    done()\n  })\n})\n\n// Run tasks:\nrun(task, 'bar', function (err) {\n  if (err) throw err\n  // ...\n})\n```\n\nTiny tasking system based on three simple functions: `create`, `add`, and `run`.\n\n## Installation\n\n```sh\n$ npm install --save tasking\n```\n\n## Usage\n\n### `tasking(name)`\n### `tasking.create(name)`\n\nCreate a task system where tasks and other meta info is stored.  `tasking.create` alias useful when destructuring\n\n - `name` (`String`): Name of the system.\n\n```js\nvar task = tasking('my-build')\n// Or:\nvar task = tasking.create('my-build')\n```\n\n**Note:** It is nice to name it `task` when used with `add(task, ...)` and `run(task, ...)`, but is also referred to as `system`\n\n### `tasking.add(system, name, [deps], [fn])`\n\nAdd task to a system.  Each task has a name associated to dependencies and/or a function\n\n - `system` (`Object`): The return system from `tasking.create`\n - `name` (`String`): Name of the task you are creaing\n - `deps` (`Array`): Tasks to run before this one starts\n - `fn` (`Function`): Function for the task.  Sync or async if it has `done` param\n\n```js\nvar add = tasking.add\n\nadd(task, 'foo', function () {\n  // Task to be run\n})\n\nadd(task, 'bar', ['foo'], function () {\n  // ...\n})\n\nadd(task, 'baz', function (done) {\n  setTimeout(function () {\n    // ...\n    done()\n  }, 1000)\n})\n\nadd(task, 'qux', ['foo', 'bar'])\n```\n\nWhen ran, the dependencies are run first.  Dependencies reference names to other tasks on the same system\n\nIf the task's function has a `done` parameter, it is ran as async, otherwise it is ran as sync\n\n### `tasking.run(system, name, [done])`\n\nRun task in system.  Will run specified dependency tasks first, but only once during the whole execution\n\n- `system` (`Object`): The return system from `tasking.create`\n- `name` (`String`|`Array`): Name or array of names of what you are running\n- `done` (`Function`): Callback after task(s) completed.  Defaults to throwing error.\n\n```js\nrun(task, 'foo', function (err) {\n  // ...\n})\n\nrun(task, ['foo', 'bar'], function (err) {\n  // ...\n})\n```\n\nIt is important to know that async tasks are run in parallel, use `add` + `run` to create serially running tasks:\n\n```js\nadd(task, 'foo', function (done) {\n  // run a dependency serially:\n  run(task, 'bar', function () {\n    // ...\n    done()\n  })\n})\n```\n\nAlso see [`async-series`](https://www.npmjs.com/package/async-series)\n\n### Structure\n\nThe system and tasks follow an easy-to-use structure:\n\n```js\n// System properties:\nsystem.name\nsystem.tasks\n\n// Get tasks by name:\nvar foo = system.tasks.foo\n\n// Task properties:\nfoo.fn\nfoo.deps\nfoo.name\n```\n\n## License\n\nMIT © [Jamen Marz](https://git.io/jamen)\n\n---\n\n[![version](https://img.shields.io/npm/v/tasking.svg?style=flat-square)][package] [![travis](https://img.shields.io/travis/jamen/tasking.svg?style=flat-square)](https://travis-ci.org/jamen/tasking) [![downloads](https://img.shields.io/npm/dt/tasking.svg?style=flat-square)][package] [![license](https://img.shields.io/npm/l/tasking.svg?style=flat-square)][package] [![support me](https://img.shields.io/badge/support%20me-paypal-green.svg?style=flat-square)](https://paypal.me/jamenmarz/5usd) [![follow](https://img.shields.io/github/followers/jamen.svg?style=social\u0026label=Follow)](https://github.com/jamen)\n\n[package]: https://npmjs.org/package/tasking\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Ftasking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamen%2Ftasking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Ftasking/lists"}