{"name":"@putout/plugin-math","version":"5.1.0","type":"module","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin helps with Math","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-math#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://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","plugin","config"],"devDependencies":{"@putout/plugin-webpack":"*","@putout/test":"^15.0.0","c8":"^10.0.0","eslint":"^10.0.0-alpha.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^30.0.0","madrun":"^12.0.0","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=41"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-math@5.1.0","gitHead":"b8e2a9c773b9d9794489dfb9dfa627fde0153d1e","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"25.3.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-fcrxLRLvpycRqlimh2K694iagmaTjzDm/QHDjkVw3T4sFVDhzyYAW+UWX9hLJ0nF9KYsr3BR8Pj2MLdAaiwysA==","shasum":"165c476c1113ce7d3e67eef99afc9c443adc44c4","tarball":"http://registry-npm.ywwl.com/@putout/plugin-math/download/@putout/plugin-math-5.1.0.tgz","fileCount":10,"unpackedSize":11384,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCKaoHAIw/KP09kuJ60MXrxRMMWUens2rRx5cW61jUQbwIhAIp6Sv7fqn/K8pxOJTy0e2lr0K/YrQmNmfPswi1YgQiF"}],"size":4078,"noattachment":false,"key":"/@putout/plugin-math/-/@putout/plugin-math-5.1.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-npm-production","tmp":"tmp/plugin-math_5.1.0_1770228535974_0.16568839627752152"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-math [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-math.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-math \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps with `Math`.\n\n## Install\n\n```\nnpm i @putout/plugin-math -D\n```\n\n## Rules\n\n- ✅ [apply-exponentiation](#apply-exponentiation);\n- ✅ [apply-multiplication](#apply-multiplication);\n- ✅ [apply-numeric-separators](#apply-numeric-separators);\n- ✅ [convert-sqrt-to-hypot](#convert-sqrt-to-hypot);\n- ✅ [declare](#declare);\n- ✅ [remove-unchanged-zero-declarations](#remove-unchanged-zero-declarations);\n\n```json\n{\n    \"rules\": {\n        \"math/apply-exponentiation\": \"on\",\n        \"math/apply-multiplication\": \"on\",\n        \"math/apply-numeric-separators\": \"on\",\n        \"math/convert-sqrt-to-hypot\": \"on\",\n        \"math/declare\": \"on\",\n        \"math/remove-unchanged-zero-declarations\": \"on\"\n    }\n}\n```\n\n## convert-sqrt-to-hypot\n\n> The `Math.hypot()` function returns the square root of the sum of squares of its arguments.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot)\n\nConvert `Math.sqrt()` to `Math.hypot()`. Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a35660f8883687ddfe53f8fbc36706ad/d83e26a547f71128f94af1d3fd542557ce820f1a).\n\n### ❌ Example of incorrect code\n\n```js\nMath.sqrt(a ** 2, b ** 2);\n```\n\n### ✅ Example of correct code\n\n```js\nMath.hypot(a, b);\n```\n\n## apply-exponentiation\n\n> - The [`Math.pow()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) static method, given two arguments, base and exponent, returns baseexponent.\n> - The [**exponentiation operator**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation) (`**`) returns the result of raising the first operand to the power of the second operand. It is equivalent to `Math.pow`, except it also accepts BigInts as operands.\n>\n> (c) MDN\n\n### ❌ Example of incorrect code\n\n```js\nMath.pow(2, 4);\n```\n\n### ✅ Example of correct code\n\n```js\n2 ** 4;\n```\n\n### Comparison\n\nLinter | Rule | Fix\n--------|-------|------------|\n🐊 **Putout** | [`convert-math-pow`](https://github.com/coderaiser/putout/tree/master/packages/plugin-convert-math-pow#readme) | ✅\n⏣ **ESLint** | [`prefer-exponentiation-operator`](https://eslint.org/docs/rules/prefer-exponentiation-operator) | ✅\n\n## apply-multiplication\n\n> Multiplying two numbers stored internally as integers (which is only possible with **AsmJS** with imul is the only potential circumstance where `Math.imul()` may prove performant in current browsers.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul)\n\nCheck out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/cef45d5cc2bfd0156ed8d483cb6104d9/89ab39b05d3093d399e718f5615efe92f484c538).\n\n### ❌ Example of incorrect code\n\n```js\nconst a = Math.imul(b, c);\n```\n\n### ✅ Example of correct code\n\n```js\nconst a = b * c;\n```\n\n## apply-numeric-separators\n\n> To improve readability for numeric literals, underscores (`_`) can be used as separators.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar)\n\n### ❌ Example of incorrect code\n\n```js\nconst t = 10000000;\n```\n\n### ✅ Example of correct code\n\n```js\nconst t = 10_000_000;\n```\n\n## declare\n\n> The `Math.round()` static method returns the value of a number rounded to the nearest integer.\n>\n> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round)\n\n### ❌ Example of incorrect code\n\n```js\nround(bLength / aLength) > 3;\n```\n\n### ✅ Example of correct code\n\n```js\nconst {round} = Math;\nround(bLength / aLength) > 3;\n```\n\n## remove-unchanged-zero-declarations\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2809d116815865ba77a5eea6ce5d8e22/3e040a89a814359b8bfb528cdbcef72f7a29d4ac).\n\n### ❌ Example of incorrect code\n\n```js\nfor (let index = 0; index < n; index++) {\n    const tokenDelta = 0;\n    const templateDelta = 0;\n    \n    for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {\n        const currentTokenIndex = index + templateIndex - tokenDelta;\n        const currentToken = tokens[currentTokenIndex];\n        \n        end = currentTokenIndex + tokenDelta;\n    }\n}\n```\n\n### ✅ Example of correct code\n\n```js\nfor (let index = 0; index < n; index++) {\n    for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {\n        const currentTokenIndex = index + templateIndex;\n        const currentToken = tokens[currentTokenIndex];\n        \n        end = currentTokenIndex;\n    }\n}\n```\n\n## License\n\nMIT\n","publish_time":1770228536120,"_cnpm_publish_time":1770228536120,"dist-tags":{"latest":"5.1.0"}}