{"id":13527669,"url":"https://github.com/developit/asyncro","last_synced_at":"2025-05-16T02:09:34.822Z","repository":{"id":57185940,"uuid":"71530653","full_name":"developit/asyncro","owner":"developit","description":"⛵️ Beautiful Array utilities for ESnext async/await ~","archived":false,"fork":false,"pushed_at":"2018-03-28T01:11:34.000Z","size":1199,"stargazers_count":489,"open_issues_count":0,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-09T11:03:01.126Z","etag":null,"topics":["accumulator","async-functions","asynchronous","filter","iteration","parallel","promise","promises"],"latest_commit_sha":null,"homepage":"https://developit.github.io/asyncro","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-21T04:46:08.000Z","updated_at":"2025-03-25T07:20:57.000Z","dependencies_parsed_at":"2022-09-06T04:12:02.049Z","dependency_job_id":null,"html_url":"https://github.com/developit/asyncro","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fasyncro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fasyncro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fasyncro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fasyncro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/asyncro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254453667,"owners_count":22073618,"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":["accumulator","async-functions","asynchronous","filter","iteration","parallel","promise","promises"],"created_at":"2024-08-01T06:01:56.354Z","updated_at":"2025-05-16T02:09:34.791Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"# `asyncro` [![NPM](https://img.shields.io/npm/v/asyncro.svg?style=flat)](https://www.npmjs.org/package/asyncro) [![travis-ci](https://travis-ci.org/developit/asyncro.svg?branch=master)](https://travis-ci.org/developit/asyncro)\n\nThe same `map()`, `reduce()` \u0026 `filter()` you know and love, but with async iterator functions!\n\nDo `fetch()` networking in loops, resolve Promises, anything async goes. Performance-friendly _by default_.\n\n**Here's what it looks like:**\n\n\u003cimg src=\"https://i.imgur.com/GcykVyN.png\" width=\"404\" alt=\"Asyncro Example\"\u003e\n\n* * *\n\n## What's in the Box\n\n\u003cimg src=\"https://i.imgur.com/yiiq6Gx.png\" width=\"275\" alt=\"Asyncro Example 2\"\u003e\n\n* * *\n\n## Installation\n\n```sh\nnpm install --save asyncro\n```\n\n## Import and Usage Example\n\n```js\nimport { map } from 'asyncro';\n\nasync function example() {\n\treturn await map(\n\t\t['foo', 'bar', 'baz'],\n\t\tasync name =\u003e fetch('./'+name)\n\t)\n}\n```\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### reduce\n\nInvoke an async reducer function on each item in the given Array,\nwhere the reducer transforms an accumulator value based on each item iterated over.\n**Note:** because `reduce()` is order-sensitive, iteration is sequential.\n\n\u003e This is an asynchronous version of `Array.prototype.reduce()`\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to reduce\n-   `reducer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function, gets passed `(accumulator, value, index, array)` and returns a new value for `accumulator`\n-   `accumulator` **\\[any]** Optional initial accumulator value\n\n**Examples**\n\n```javascript\nawait reduce(\n\t['/foo', '/bar', '/baz'],\n\tasync (accumulator, value) =\u003e {\n\t\taccumulator[v] = await fetch(value);\n\t\treturn accumulator;\n\t},\n\t{}\n);\n```\n\nReturns **any** final `accumulator` value\n\n### map\n\nInvoke an async transform function on each item in the given Array **in parallel**,\nreturning the resulting Array of mapped/transformed items.\n\n\u003e This is an asynchronous, parallelized version of `Array.prototype.map()`.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to map over\n-   `mapper` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function, gets passed `(value, index, array)`, returns the new value.\n\n**Examples**\n\n```javascript\nawait map(\n\t['foo', 'baz'],\n\tasync v =\u003e await fetch(v)\n)\n```\n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** resulting mapped/transformed values.\n\n### filter\n\nInvoke an async filter function on each item in the given Array **in parallel**,\nreturning an Array of values for which the filter function returned a truthy value.\n\n\u003e This is an asynchronous, parallelized version of `Array.prototype.filter()`.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to filter\n-   `filterer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function. Gets passed `(value, index, array)`, returns true to keep the value in the resulting filtered Array.\n\n**Examples**\n\n```javascript\nawait filter(\n\t['foo', 'baz'],\n\tasync v =\u003e (await fetch(v)).ok\n)\n```\n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** resulting filtered values\n\n### find\n\nInvoke an async function on each item in the given Array **in parallel**,\n returning the first element predicate returns truthy for.\n\n\u003e This is an asynchronous, parallelized version of `Array.prototype.find()`.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to find\n-   `predicate` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function. Gets passed `(value, index, array)`, returns true to be the find result.\n\n**Examples**\n\n```javascript\nawait find(\n\t['foo', 'baz', 'root'],\n\tasync v =\u003e (await fetch(v)).name === 'baz'\n)\n```\n\nReturns **any** resulting find value\n\n### every\n\nChecks if predicate returns truthy for **all** elements of collection **in parallel**.\n\n\u003e This is an asynchronous, parallelized version of `Array.prototype.every()`.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to iterate over.\n-   `predicate` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function. Gets passed `(value, index, array)`, The function invoked per iteration.\n\n**Examples**\n\n```javascript\nawait every(\n\t[2, 3],\n\tasync v =\u003e (await fetch(v)).ok\n)\n```\n\nReturns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns true if **all** element passes the predicate check, else false.\n\n### some\n\nChecks if predicate returns truthy for **any** element of collection **in parallel**.\n\n\u003e This is an asynchronous, parallelized version of `Array.prototype.some()`.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The Array to iterate over.\n-   `filterer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Async function. Gets passed `(value, index, array)`, The function invoked per iteration.\n\n**Examples**\n\n```javascript\nawait some(\n\t['foo', 'baz'],\n\tasync v =\u003e (await fetch(v)).ok\n)\n```\n\nReturns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns true if **any** element passes the predicate check, else false.\n\n### parallel\n\nInvoke all async functions in an Array or Object **in parallel**, returning the result.\n\n**Parameters**\n\n-   `list` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)\u003e | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\u0026lt;[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)\u003e)** Array/Object with values that are async functions to invoke.\n\n**Examples**\n\n```javascript\nawait parallel([\n\tasync () =\u003e await fetch('foo'),\n\tasync () =\u003e await fetch('baz')\n])\n```\n\nReturns **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \\| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** same structure as `list` input, but with values now resolved.\n\n### series\n\nInvoke all async functions in an Array or Object **sequentially**, returning the result.\n\n**Parameters**\n\n-   `list` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)\u003e | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\u0026lt;[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)\u003e)** Array/Object with values that are async functions to invoke.\n\n**Examples**\n\n```javascript\nawait series([\n\tasync () =\u003e await fetch('foo'),\n\tasync () =\u003e await fetch('baz')\n])\n```\n\nReturns **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \\| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** same structure as `list` input, but with values now resolved.\n\n## License\n\n[MIT](https://oss.ninja/mit/developit)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fasyncro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fasyncro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fasyncro/lists"}