{"_id":"reduce-first","_rev":"204350","name":"reduce-first","description":"Return early from reduce","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"bconnorwhite","email":""},{"name":"npm:bconnorwhite","email":""}],"time":{"modified":"2023-03-21T13:41:40.000Z","created":"2020-09-10T04:17:47.929Z","2.0.0":"2023-01-10T22:52:30.177Z","1.0.1":"2020-09-10T04:25:20.613Z","1.0.0":"2020-09-10T04:17:47.929Z"},"users":{},"author":{"name":"Connor White"},"repository":{"type":"git","url":"git+https://github.com/bconnorwhite/reduce-first.git"},"versions":{"2.0.0":{"name":"reduce-first","version":"2.0.0","description":"Return early from reduce","license":"MIT","private":false,"author":{"name":"Connor White"},"contributors":[{"name":"Connor White"}],"homepage":"https://connorwhite.org/github/reduce-first","repository":{"type":"git","url":"git+https://github.com/bconnorwhite/reduce-first.git"},"bugs":{"url":"https://github.com/bconnorwhite/reduce-first/issues"},"keywords":["reduce","first","find","search","array","item","items"],"type":"module","main":".auto/build/index.js","exports":"./.auto/build/index.js","types":".auto/build/index.d.ts","engines":{"node":"^14.13.1 || >=16.0.0"},"scripts":{"build":"auto build","dev":"auto dev","lint":"auto lint","prepack":"yarn build","release":"auto release","test":"auto test","typecheck":"auto typecheck"},"devDependencies":{"autorepo":"^0.1.9"},"eslintConfig":{"extends":"@autosoft/eslint-config"},"jest":{"preset":"@autosoft/jest-preset"},"npmpackagejsonlint":{"extends":"npm-package-json-lint-config-auto"},"_id":"reduce-first@2.0.0","dist":{"shasum":"84eeb922b93fb413ed4d825e7e30210ed20c0035","size":2020,"noattachment":false,"key":"/reduce-first/-/reduce-first-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/reduce-first/download/reduce-first-2.0.0.tgz"},"_npmUser":{"name":"bconnorwhite","email":"connor.bcw@gmail.com"},"directories":{},"maintainers":[{"name":"bconnorwhite","email":""},{"name":"npm:bconnorwhite","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reduce-first_2.0.0_1673391150042_0.4720230017310034"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-01-10T22:52:30.177Z","publish_time":1673391150177,"_cnpm_publish_time":1673391150177},"1.0.1":{"name":"reduce-first","version":"1.0.1","description":"Return early from reduce","license":"MIT","author":{"name":"Connor White","email":"connor.bcw@gmail.com","url":"https://connorwhite.org"},"homepage":"https://connorwhite.org/github/reduce-first","repository":{"type":"git","url":"git+https://github.com/bconnorwhite/reduce-first.git"},"keywords":["reduce","first","find","search","array","item","items"],"main":"./build/index.js","scripts":{"build":"bob build","postversion":"git push","prepublishOnly":"yarn run build && yarn run test","test":"jest"},"devDependencies":{"@bconnorwhite/bob":"^2.1.0","jest":"^26.4.2"},"_id":"reduce-first@1.0.1","dist":{"shasum":"ef934f0dd4e010fdcaec2c51c9027722ee810c1c","size":1484,"noattachment":false,"key":"/reduce-first/-/reduce-first-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/reduce-first/download/reduce-first-1.0.1.tgz"},"maintainers":[{"name":"bconnorwhite","email":""},{"name":"npm:bconnorwhite","email":""}],"_npmUser":{"name":"bconnorwhite","email":"connor.bcw@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reduce-first_1.0.1_1599711920515_0.14581857898406314"},"_hasShrinkwrap":false,"publish_time":1599711920613,"_cnpm_publish_time":1599711920613,"_cnpmcore_publish_time":"2021-12-17T00:21:56.288Z"},"1.0.0":{"name":"reduce-first","version":"1.0.0","description":"Return early from reduce","license":"MIT","author":{"name":"Connor White","email":"connor.bcw@gmail.com","url":"https://connorwhite.org"},"homepage":"https://connorwhite.org/github/reduce-first","repository":{"type":"git","url":"git+https://github.com/bconnorwhite/reduce-first.git"},"keywords":["reduce","first","find","search","array","item","items"],"main":"./build/index.js","scripts":{"build":"bob build","postversion":"git push","prepublishOnly":"yarn run build && yarn run test","test":"jest"},"devDependencies":{"@bconnorwhite/bob":"^2.1.0","jest":"^26.4.2"},"_id":"reduce-first@1.0.0","dist":{"shasum":"03de12840ecf6a3ec0916c46c10eee6ff3cb578c","size":1482,"noattachment":false,"key":"/reduce-first/-/reduce-first-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/reduce-first/download/reduce-first-1.0.0.tgz"},"maintainers":[{"name":"bconnorwhite","email":""},{"name":"npm:bconnorwhite","email":""}],"_npmUser":{"name":"bconnorwhite","email":"connor.bcw@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/reduce-first_1.0.0_1599711467813_0.06812870260325421"},"_hasShrinkwrap":false,"publish_time":1599711467929,"_cnpm_publish_time":1599711467929,"_cnpmcore_publish_time":"2021-12-17T00:21:56.660Z"}},"readme":"<!--BEGIN HEADER-->\n<div id=\"top\" align=\"center\">\n  <h1>reduce-first</h1>\n  <a href=\"https://npmjs.com/package/reduce-first\">\n    <img alt=\"NPM\" src=\"https://img.shields.io/npm/v/reduce-first.svg\">\n  </a>\n  <a href=\"https://github.com/bconnorwhite/reduce-first\">\n    <img alt=\"TypeScript\" src=\"https://img.shields.io/github/languages/top/bconnorwhite/reduce-first.svg\">\n  </a>\n</div>\n\n<br />\n\n<blockquote align=\"center\">Return early from reduce.</blockquote>\n\n<br />\n\n_If I should maintain this repo, please ⭐️_\n<a href=\"https://github.com/bconnorwhite/reduce-first\">\n  <img align=\"right\" alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/bconnorwhite/reduce-first?label=%E2%AD%90%EF%B8%8F&style=social\">\n</a>\n\n_DM me on [Twitter](https://twitter.com/bconnorwhite) if you have questions or suggestions._\n<a href=\"https://twitter.com/bconnorwhite\">\n  <img align=\"right\" alt=\"Twitter\" src=\"https://img.shields.io/twitter/url?label=%40bconnorwhite&style=social&url=https%3A%2F%2Ftwitter.com%2Fbconnorwhite\">\n</a>\n\n---\n<!--END HEADER-->\n\n`Array.prototype.find` returns the element from an array, and `Array.prototype.reduce` allows you to map to antother value. `reduceFirst` combines these to return a transformation of the first item that returns a value.\n\n## Installation\n\n```sh\nyarn add reduce-first\n```\n\n```sh\nnpm install reduce-first\n```\n\n```sh\npnpm add reduce-first\n```\n\n## Usage\n\n```ts\nimport reduceFirst from \"reduce-first\";\n\nconst list = [\"a\", \"b\", \"c\", \"d\", \"e\"];\n\nconst result1 = reduceFirst(list, (value, index, arr) => {\n  if(value === \"c\") {\n    return `found ${value}`;\n  }\n});\n// result1 === \"found c\"\n\nconst result2 = reduceFirst(list, (value, index, arr) => {\n  if(value === \"x\") {\n    return `found ${value}`;\n  }\n});\n// result2 === undefined\n```\n\n<!--BEGIN FOOTER-->\n\n<br />\n\n<h2>Dev Dependencies</h2>\n\n- [autorepo](https://www.npmjs.com/package/autorepo): Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.\n\n<br />\n\n<h2 id=\"license\">License <a href=\"https://opensource.org/licenses/MIT\"><img align=\"right\" alt=\"license\" src=\"https://img.shields.io/npm/l/reduce-first.svg\"></a></h2>\n\n[MIT](https://opensource.org/licenses/MIT) - _MIT License_\n<!--END FOOTER-->\n","_attachments":{},"homepage":"https://connorwhite.org/github/reduce-first","bugs":{"url":"https://github.com/bconnorwhite/reduce-first/issues"},"license":"MIT"}