{"id":15646434,"url":"https://github.com/martinheidegger/map-each","last_synced_at":"2025-03-29T23:17:11.840Z","repository":{"id":72874200,"uuid":"164142764","full_name":"martinheidegger/map-each","owner":"martinheidegger","description":"A very small, flexible, parallel async mapping helper that has first-class support for Iterators and concurrency.","archived":false,"fork":false,"pushed_at":"2020-06-16T15:20:54.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-07T20:38:20.228Z","etag":null,"topics":["async","callback","concurrency","each","iterable","iterator","javascript","mapping","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-04T18:41:45.000Z","updated_at":"2020-06-17T15:59:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ecd148d-ef87-47f5-b244-846b93cce254","html_url":"https://github.com/martinheidegger/map-each","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"c8986861fb0ddffe5b06305d0361829f0ba9e4c8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fmap-each","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fmap-each/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fmap-each/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fmap-each/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinheidegger","download_url":"https://codeload.github.com/martinheidegger/map-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","mapping","parallel"],"created_at":"2024-10-03T12:12:51.813Z","updated_at":"2025-03-29T23:17:11.804Z","avatar_url":"https://github.com/martinheidegger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# map-each\n\n\u003ca href=\"https://travis-ci.org/martinheidegger/map-each\"\u003e\u003cimg src=\"https://travis-ci.org/martinheidegger/map-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/145d866d11ece4da9e69/maintainability)](https://codeclimate.com/github/martinheidegger/map-each/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/145d866d11ece4da9e69/test_coverage)](https://codeclimate.com/github/martinheidegger/map-each/test_coverage)\n\n`map-each` is a **very small**, **flexible**, **parallel** async mapping 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 map-each --save`\n\nIt is similar to [`async-iterate`][], [`now-and-later`][], [`async-parallel`][], ... and many other.\n\n```javascript\nconst { mapEach } = require('map-each')\n\nmapEach(\n  ['a', 'b', 'c']\n  function (input, callback) {\n    callback()\n  },\n  function (err) {\n    // Done once all functions are done\n  }\n)\n```\n\n[`async-iterate`]: https://www.npmjs.com/package/async-iterate\n[`now-and-later`]: https://www.npmjs.com/package/now-and-later\n[`async-parallel`]: https://www.npmjs.com/package/async-parallel\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\nmapEach([\n  ['a', 'b']\n  function (item, callback) {\n    callback(null, 'name:' + item)\n  },\n], function (err, data) {\n  Array.from(data) === ['name:a', 'name: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\nmapEach([], function () {}, function () {\n  console.log(arguments.length) // 1\n})\n\nmapEach([], function () {}, 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\nmapEach([/*...*/], function () {}).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\nmapEach([/*...*/], function () {}, 1).then(function () {\n  // now each operation is run in series.\n})\nmapEach([/*...*/], function () {}, 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%2Fmap-each","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinheidegger%2Fmap-each","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Fmap-each/lists"}