{"name":"@putout/plugin-convert-reduce-to-for-of","version":"1.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to convert '.reduce()' to 'for...of'","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-reduce-to-for-of#readme","main":"lib/convert-reduce-to-for-of.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["putout","putout-plugin","putout-plugin-convert","plugin","convert","reduce","for-of"],"devDependencies":{"@putout/test":"^5.0.0","c8":"^7.5.0","eslint":"^8.0.1","eslint-plugin-node":"^11.0.0","eslint-plugin-putout":"^15.0.0","madrun":"^9.0.0"},"peerDependencies":{"putout":">=25"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"gitHead":"584d6f18e39ed4c26831a1477e7ca519fc517bf4","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_id":"@putout/plugin-convert-reduce-to-for-of@1.0.0","_nodeVersion":"18.0.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-nVaI8XlBb54zAnbkSPwjIPQqkZbPsHgy/oxi0S6jiSncT9b+lkWdS8RiRq+p0Yf13mNqCMsV+tSncGwC3AF9Jw==","shasum":"130cb5cd32dd6876335d351bf36d432657a8bc90","tarball":"http://registry-npm.ywwl.com/@putout/plugin-convert-reduce-to-for-of/download/@putout/plugin-convert-reduce-to-for-of-1.0.0.tgz","fileCount":4,"unpackedSize":5692,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5JAxSi0i+RH5EdkUpwOB6Th8rz4aNUGhOhcUAIRKZqwIhAKnATUHaelwj6uoDGcmGvxmtaxOdOOByXgnJM3ChZR+m"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibt+9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoblQ/7BQ2jgGa50bHx6rdUeRW0vijXezqaSXmi3/7RHAQM3OZarZJj\r\nG+MzbOxrGujDu1P6GEbkxle5tOi00lgcaKsVwp8rxxVG72WwGmF4JpVHbe14\r\n5rhQwA2plEIMgJO7UnNnmxCTA8gRBPEu45ov9xjJeVEq4JYTX8JLYbjPPnP3\r\nQQN3V6ncsR4S5ouSEAjdoy6GKnxqzUHgFYyWOMvbdFmgVDN9CTgW2yEYhkfR\r\nLMwCYC4Dmc38VcALzUZ0iJMHK5oVqb2lMMiHs2GpOOwz2db2D+dNYMQwljZh\r\nlEQTKp9dLs4rPq/Nb8cQVfDhXLESZ4UXfrYPEWnD3bpJpp6tGFNqgvSQIH1G\r\nP/MAgK218phhDtQ8mwXvKjnWi/LehjheWOH0dtzV7f9jdYed/Ie8jQ8ICSd6\r\n+Sm5uF0IQqPNAQyDVPxUcbfaIaecksHcGKJC5pWhcHa6TA+5l6KwUvOSdWAU\r\nXETvDROWN9oK5gc2lNBtfNd86IdmqpZaEg8mT35ayD33TqpFgJ8Qc9lDzfBk\r\nkd1wkfE7xzOWMmyJekRURBsAcuYT/kf4biKMH30PWgj7MhzQkjQc1naOE72V\r\nEbqB8C4gdtwySyOuZg4LHx30Ef91ldSkGgGgEOgVPGeK9M3rzvSYZ3yyckzo\r\nHE0CkYfuF0U4cc4F9lu0DeEsInnh0lMXiRA=\r\n=CpVh\r\n-----END PGP SIGNATURE-----\r\n","size":2462,"noattachment":false,"key":"/@putout/plugin-convert-reduce-to-for-of/-/@putout/plugin-convert-reduce-to-for-of-1.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-convert-reduce-to-for-of_1.0.0_1651433404816_0.7299256133858532"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-convert-reduce-to-for-of [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-convert-reduce-to-for-of.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-convert-reduce-to-for-of \"npm\"\n\n> - The [`reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) method executes a user-supplied **reducer** callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.\n>\n> - The [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) statement creates a loop which invokes a custom iteration hook with statements to be executed for the value of each element of an array.\n>\n> (c) MDN\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to convert `.reduce()` to `for...of` loop. Merged to [`@putout/plugin-for-of`](https://www.npmjs.com/package/@putout/plugin-for-of).\nYou should always look at second argument of a **reducer** since it changes logic drastically and should read back and forth a couple times to understand what is going on.\n\n> Recursive functions like `.reduce()` can be powerful but sometimes difficult to understand, especially for less experienced **JavaScript** developers. If code becomes clearer when using other array methods, developers must weigh the readability tradeoff against the other benefits of using `.reduce()`. In cases where `.reduce()` is the best choice, documentation and semantic variable naming can help mitigate readability drawbacks.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#when_to_not_use_reduce)\n\nCheck it out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/107751499a4bbdd83b9181444d8bdbbd/8d3b646a3df0025d564e2bb141cc7f6a6bb1b3a5).\n\n## Install\n\n```\nnpm i @putout/plugin-convert-reduce-to-for-of -D\n```\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"convert-reduce-to-for-of\": \"on\"\n    }\n}\n```\n\n## ❌ Example of incorrect code\n\n```js\nconst result = list.reduce((a, b) => a + b, 1);\n```\n\n## ✅ Example of correct code\n\n```js\nlet sum = 1;\n\nfor (const a of list) {\n    sum += a;\n}\n```\n\n## License\n\nMIT\n","publish_time":1651433404995,"_cnpm_publish_time":1651433404995,"dist-tags":{"latest":"1.4.1"}}