{"id":15646453,"url":"https://github.com/martinheidegger/run-each","last_synced_at":"2025-03-29T23:17:19.094Z","repository":{"id":57355814,"uuid":"164138209","full_name":"martinheidegger/run-each","owner":"martinheidegger","description":"A very small, flexible, parallel async iteration helper that has first-class support for Iterators and concurrency.","archived":false,"fork":false,"pushed_at":"2019-01-04T18:06:47.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T02:39:03.806Z","etag":null,"topics":["async","callback","concurrency","each","iterable","iterator","javascript","parallel"],"latest_commit_sha":null,"homepage":null,"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/martinheidegger.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-04T17:50:13.000Z","updated_at":"2019-01-06T04:14:42.000Z","dependencies_parsed_at":"2022-09-05T22:12:41.966Z","dependency_job_id":null,"html_url":"https://github.com/martinheidegger/run-each","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Frun-each","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Frun-each/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Frun-each/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Frun-each/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinheidegger","download_url":"https://codeload.github.com/martinheidegger/run-each/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246254149,"owners_count":20747949,"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":["async","callback","concurrency","each","iterable","iterator","javascript","parallel"],"created_at":"2024-10-03T12:12:58.240Z","updated_at":"2025-03-29T23:17:19.066Z","avatar_url":"https://github.com/martinheidegger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# run-each\n\n\u003ca href=\"https://travis-ci.org/martinheidegger/run-each\"\u003e\u003cimg src=\"https://travis-ci.org/martinheidegger/run-each.svg?branch=master\" alt=\"Build Status\"/\u003e\u003c/a\u003e\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Maintainability](https://api.codeclimate.com/v1/badges/338cdb4001fbee61ad73/maintainability)](https://codeclimate.com/github/martinheidegger/run-each/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/338cdb4001fbee61ad73/test_coverage)](https://codeclimate.com/github/martinheidegger/run-each/test_coverage)\n\n`run-each` is a **very small**, **flexible**, **parallel** async iteration helper that has first-class support for [Iterators][]\n(unlike other libraries, which mostly break with iterators) and **concurrency**. It also has complete TypeScript header files for\ncomfortable integration.\n\n[Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\n\n`npm i run-each --save`\n\nIt is similar to [`each`][], [`async-each`][], [`each-async`][], ... and many other.\n\n```javascript\nconst { runEach } = require('run-each')\n\nrunEach(\n  [\n    function (callback) {\n      callback()\n    },\n    function (callback) {\n      callback()\n    }\n  ],\n  function (err) {\n    // Done once all functions are done\n  }\n)\n```\n\n[`each`]: https://www.npmjs.com/package/each\n[`async-each`]: https://www.npmjs.com/package/each\n[`each-async`]: https://www.npmjs.com/package/each-async\n\nThere are several things that make this different:\n\n- It returns an `Iterable` object instead of an Array.\n- It supports `Promises` in case you prefer to use async/await with your API's\n- It supports `concurrency` limits to limit the amount of commands executed at the same time.\n\n\n## Iterable results\n\nLike in other libraries you can get the result, but unlike other libraries, its not\nan Array, so you need to apply an `Array.from` to it.\n\n```javascript\nrunEach([\n  function (callback) {\n    callback('a')\n  },\n  function (callback) {\n    callback('b')\n  }\n], function (err, data) {\n  Array.from(data) === ['a', 'b'] // the order is protected\n})\n```\n\n_Note:_ This is more of an internal detail, but if the passed-in function doesn't have\na second parameter, the data will not be collected.\n\n```javascript\nrunEach([], function () {\n  console.log(arguments.length) // 1\n})\n\nrunEach([], function (err, data) {\n  console.log(arguments.length) // 2\n})\n```\n\n## Promise support\n\nIf you don't pass in a callback handler at the end, it will automatically return a Promise.\n\n```javascript\nrunEach([/*...*/]).then(function () {\n  // all done\n})\n```\n\n## Concurrency\n\nBy passing a concurrency limit to the runner, it will limit the amount of parallel\nexecutions\n\n```javascript\nrunEach([/*...*/], 1).then(function () {\n  // now each operation is run in series.\n})\nrunEach([/*...*/], 2).then(function () {\n  // now two operations are run at the same time\n})\n```\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Frun-each","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinheidegger%2Frun-each","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Frun-each/lists"}