{"id":17736600,"url":"https://github.com/parro-it/ai-reduce","last_synced_at":"2025-03-31T19:17:06.042Z","repository":{"id":57174775,"uuid":"111198172","full_name":"parro-it/ai-reduce","owner":"parro-it","description":"Reduce for async iterables.","archived":false,"fork":false,"pushed_at":"2017-12-04T20:19:19.000Z","size":470,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T03:04:28.342Z","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/parro-it.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-11-18T11:00:09.000Z","updated_at":"2017-11-18T11:01:22.000Z","dependencies_parsed_at":"2022-08-29T00:10:36.822Z","dependency_job_id":null,"html_url":"https://github.com/parro-it/ai-reduce","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fai-reduce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fai-reduce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fai-reduce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fai-reduce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parro-it","download_url":"https://codeload.github.com/parro-it/ai-reduce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246523847,"owners_count":20791444,"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-26T00:23:42.967Z","updated_at":"2025-03-31T19:17:06.014Z","avatar_url":"https://github.com/parro-it.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ai-reduce\n\n[![Travis Build Status](https://img.shields.io/travis/parro-it/ai-reduce/master.svg)](http://travis-ci.org/parro-it/ai-reduce)\n[![NPM downloads](https://img.shields.io/npm/dt/ai-reduce.svg)](https://npmjs.org/package/ai-reduce)\n\n\u003e Reduce for async iterables.\n\nThe reduce() method applies a function against an accumulator and each element\nin the async iterable (from left to right) to reduce it to a single value.\n\n## Async iterable fun\n\n\u003e **_This module is part of\n\u003e [Async iterable fun](https://github.com/parro-it/ai-fun), a complete toolset\n\u003e of modules to work with async iterables._**\n\n## Usage\n\n_Reduce to an async iterable to the sum of its elements:_\n\n```js\nimport reduce from(\"ai-reduce\");\nconst add = (accum, item) =\u003e accum + item;\nconsole.log( await reduce([2, 3], add, 1) );\n```\n\nThis will output 6\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### reduce\n\nThe reduce() method applies a function against an accumulator and each element\nin the async iterable to reduce it to a single promise.\n\n**Parameters**\n\n* `data` **AsyncIterable** The async iterable to reduce\n* `reducer`\n  **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**\n  Function to execute on each element in the async iterable, taking four\n  arguments: . ```\n\n\n        __accumulator__ - The accumulator accumulates the callback's return values; it is\n        the accumulated value previously returned in the last invocation of the\n        callback, or initialValue, if supplied (see below).\n\n        __currentValue__ - The current element being processed in the async iterable.\n\n        __currentIndex__ - The index of the current element being processed in the async\n        iterable. Starts at index 0, if an initialValue is provided, and at index 1\n        otherwise.\n\n        __data__ - The async iterable reduce was called upon.\n        ```\n\n* `initialValue` **any** Value to use as the first argument to the first call of\n  the callback. If no initial value is supplied, the first element in the async\n  iterable will be used. Calling reduce on an empty async iterable without an\n  initial value is an error.\n\nReturns\n**[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**\nThe promise value that results from the reduction.\n\n### with\n\nHigher order function that partially apply `reducer` and `accumulator` arguments\nto the reduce function.\n\n**Parameters**\n\n* `reducer`\n  **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**\n  The reducer argument to partially apply\n* `accumulator` **any** The accumulator argument to partially apply\n\nReturns\n**[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**\nA `reduce` unary function that take a data argument\n\n## Install\n\nWith [npm](https://npmjs.org/) installed, run\n\n```bash\nnpm install --save ai-reduce\n```\n\n## See Also\n\n* [`noffle/common-readme`](https://github.com/noffle/common-readme)\n* [`parro-it/ai-fun`](https://github.com/parro-it/ai-fun)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fai-reduce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparro-it%2Fai-reduce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fai-reduce/lists"}