{"_id":"reduce-first","_rev":"229688","name":"reduce-first","description":"Return early from reduce","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"bconnorwhite","email":"connor.bcw@gmail.com"}],"time":{"modified":"2021-06-03T15:45:10.000Z","created":"2020-09-10T04:17:47.929Z","1.0.1":"2020-09-10T04:25:20.613Z","1.0.0":"2020-09-10T04:17:47.929Z"},"users":{},"author":{"name":"Connor White","email":"connor.bcw@gmail.com","url":"https://connorwhite.org"},"repository":{"type":"git","url":"git+https://github.com/bconnorwhite/reduce-first.git"},"versions":{"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://registry.cnpm.dingdandao.com/reduce-first/download/reduce-first-1.0.1.tgz"},"maintainers":[{"name":"bconnorwhite","email":"connor.bcw@gmail.com"}],"_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},"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://registry.cnpm.dingdandao.com/reduce-first/download/reduce-first-1.0.0.tgz"},"maintainers":[{"name":"bconnorwhite","email":"connor.bcw@gmail.com"}],"_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}},"readme":"<div 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  <a href=\"https://github.com/bconnorwhite/reduce-first\">\n    <img alt=\"GitHub stars\" src=\"https://img.shields.io/github/stars/bconnorwhite/reduce-first?label=Stars%20Appreciated%21&style=social\">\n  </a>\n  <a href=\"https://twitter.com/bconnorwhite\">\n    <img alt=\"Twitter Follow\" src=\"https://img.shields.io/twitter/follow/bconnorwhite.svg?label=%40bconnorwhite&style=social\">\n  </a>\n</div>\n\n<br />\n\n> Return early from reduce.\n\n`.find()` returns the element from an array, and `.reduce()` loops over every element. `reduceFirst` combines these to return a transformation of the first item that returns a value.\n\n## Installation\n\n```bash\nyarn add reduce-first\n```\n\n```bash\nnpm install reduce-first\n```\n\n## API\n\n```ts\nimport reduceFirst from \"reduce-first\";\n\nconst list = [\"a\", \"b\", \"c\", \"d\", \"e\"];\n\nreduceFirst(list, (value, index, arr) => {\n  if(value === \"c\") {\n    return `found ${value}`;\n  }\n}); // \"found c\"\n\nreduceFirst(list, (value, index, arr) => {\n  if(value === \"x\") {\n    return `found ${value}`;\n  }\n}); // undefined\n```\n\n<br />\n\n<h2>Dev Dependencies<img align=\"right\" alt=\"David\" src=\"https://img.shields.io/david/dev/bconnorwhite/reduce-first.svg\"></h2>\n\n- [@bconnorwhite/bob](https://www.npmjs.com/package/@bconnorwhite/bob): Bob is a toolkit for TypeScript projects\n- [jest](https://www.npmjs.com/package/jest): Delightful JavaScript Testing.\n\n\n<h2>License <img align=\"right\" alt=\"license\" src=\"https://img.shields.io/npm/l/reduce-first.svg\"></h2>\n\n[MIT](https://opensource.org/licenses/MIT)\n","_attachments":{},"homepage":"https://connorwhite.org/github/reduce-first","license":"MIT"}