{"id":16773847,"url":"https://github.com/ziflex/piperline","last_synced_at":"2025-09-08T09:32:39.252Z","repository":{"id":34635950,"uuid":"38588083","full_name":"ziflex/piperline","owner":"ziflex","description":"Simple task pipeline runner","archived":false,"fork":false,"pushed_at":"2023-03-04T04:21:37.000Z","size":823,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-23T08:01:41.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"AliasIO/Wappalyzer","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziflex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2015-07-05T23:31:20.000Z","updated_at":"2021-12-28T16:34:38.000Z","dependencies_parsed_at":"2024-10-13T06:47:14.282Z","dependency_job_id":"bcd6b90e-a189-4c31-9cb0-164a18b3dc6d","html_url":"https://github.com/ziflex/piperline","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":0.5405405405405406,"last_synced_commit":"af32915eb9f988af46c7f706765ccdc28b840825"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fpiperline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fpiperline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fpiperline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziflex%2Fpiperline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziflex","download_url":"https://codeload.github.com/ziflex/piperline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248287905,"owners_count":21078805,"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-13T06:47:11.280Z","updated_at":"2025-04-10T20:04:05.002Z","avatar_url":"https://github.com/ziflex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# piperline\n\n\u003e Split your async code into small tasks.\n\nSimple task pipeline runner which allows you to split you async code into small tasks.\n\n[![npm version](https://badge.fury.io/js/piperline.svg)](https://www.npmjs.com/package/piperline)\n[![Actions Status](https://github.com/ziflex/piperline/workflows/Node%20CI/badge.svg)](https://github.com/ziflex/piperline/actions)\n\n## Installation\n\nnpm\n\n```sh\n\n$ npm install --save piperline\n\n```\n\n\n## Features\n* async tasks\n* re-usage\n* interruption\n* extensibility\n* event-based control\n\n## Usage\n\n### Basic\n\n```javascript\n\nvar Piperline = require('piperline');\n\nPiperline.create()\n    .pipe(function(data, next, done) {\n        next('foo');\n    })\n    .pipe(function(data, next, done) {\n        next(data + ' bar');\n    })\n    .on('error', function(err) {\n        console.error(err);\n    })\n    .on('done', function(result) {\n        console.log(result); // foo bar\n    })\n    .run();\n```\n\n### Passing initial data\n\n```javascript\n\nvar Piperline = require('piperline');\n\nPiperline.create()\n    .pipe(function(data, next, done) {\n        next(data + 1);\n    })\n    .pipe(function(data, next, done) {\n        next(data + 2);\n    })\n    .on('error', function(err) {\n        console.error(err);\n    })\n    .on('done', function(result) {\n        console.log(result); // 4\n    })\n    .run(1);\n```\n\n### Passing callback\n\n```javascript\n\nvar pipeline = require('piperline').create();\n\npipeline\n    .pipe(function(data, next, done) {\n        next(data + 1);\n    })\n    .pipe(function(data, next, done) {\n        next(data + 2);\n    })\n    .on('error', function(err) {\n        console.error(err);\n    })\n    .on('done', function(result) {\n        console.log(result); // 3\n    })\n    .run(0, function(err, data) {\n        if (err) {\n            // do stuff\n        }\n    });\n```\n\n### Pipeline interruption\n\n```javascript\n\nvar Piperline = require('piperline');\n\nPiperline.create()\n    .pipe(function(data, next, done) {\n        next(data + 1);\n    })\n    .pipe(function(data, next, done) {\n        if (data === 1) {\n            done(data);\n        }\n\n        next(data + 2);\n    })\n    .pipe(function(data, next, done) {\n        next(data + 3);\n    })\n    .on('error', function(err) {\n        console.error(err);\n    })\n    .on('done', function(result) {\n        console.log(result); // 1\n    })\n    .run(0);\n```\n\n### Re-usage\n\n```javascript\n\nvar pipeline = require('piperline').create();\n\npipeline\n    .pipe(function(data, next, done) {\n        // do stuff\n        next();\n    })\n    .pipe(function(data, next, done) {\n        // do stuff\n        next();\n    })\n    .on('finish', () =\u003e {\n        // everything is completed\n    });\n\n[1, 2, 3, 4].forEach(data =\u003e pipeline.run(data));\n\n```\n\n### Manual error emitting\n\nEmitting error via callback (``done`` or ``next``) by passing ``Error`` object.\n\n```javascript\n\nvar pipeline = require('piperline').create();\n\npipeline\n    .pipe(function(data, next) {\n        next(data);\n    })\n    .pipe(function(data, next, done) {\n        done(new Error());\n    })\n    .on('error', function(err) {\n      console.log(err); // Error\n    })\n    .run(0);\n```\n\n## API\n\n### piperline.create()\n\nCreates a new pipeline runner.\n\n### .pipe(function(data, next, done))\n\nAdds pipe for execution.\nCan be invoked only before or after execution.\n\n`data` - any data passed from top pipes or `run` method.\n\n`next` - callback which invokes next pipe or completes the execution.\nAny passed data to this callback will be transferred to the next pipe.\n\n`done` - callback which terminates the execution of the whole pipeline.\n\n\n**Note: If `Error` object will be passed to one of these callbacks it will be treated as termination of execution\nand `error` event will be emitted with this object.**\n\n### .run([data],[function(error, result)])\n\nBuilds and runs the execution.\n\n`data` - any initial data which will be passed to the first pipe.\n\n`callback` - callback which will be called when the execution is completed.\n\n### .isRunning()   \n\nDetects whether the pipeline is executing.   \n\n### .on('run', function())   \n\nFired every time when execution started and there are no already running in background.  \n\n### .on('finish', function())   \n\nFired every time when execution completed and there are no already running in background.  \n\n### .on('done', function(result))   \n\nFired for each successful execution.   \n\n### .on('error', function(error))   \n\nFired for each failed execution.   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziflex%2Fpiperline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziflex%2Fpiperline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziflex%2Fpiperline/lists"}