{"name":"@putout/plugin-math","version":"3.2.0","type":"commonjs","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","putout","config"],"devDependencies":{"@putout/plugin-webpack":"*","@putout/test":"^11.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^23.0.0","lerna":"^6.0.1","madrun":"^10.0.0","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=37"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-math@3.2.0","gitHead":"409e6ed5eea87406a585fe0869f8d38acc82b3b1","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"20.18.1","_npmVersion":"10.9.0","dist":{"integrity":"sha512-r41TOIPt40lrX6F5Lg7FzXSB6Jd1d+enqkxAQhrnDrxNLS1DGiJpHK/PiQkC1cVwkiqYvG9lHdACut/ovPwQTQ==","shasum":"811d193f4dc12c024902ea7da2b851e747a68518","tarball":"http://registry-npm.ywwl.com/@putout/plugin-math/download/@putout/plugin-math-3.2.0.tgz","fileCount":10,"unpackedSize":11122,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQChUImn8tRHUFrAJr+Fan+YYUwZolq/Oi9OCGIM7T6GZAIhAIqgneLj99l+efF6Yhlv8ttjBf6WbwRzBCe5WL0W1wrB"}],"size":4023,"noattachment":false,"key":"/@putout/plugin-math/-/@putout/plugin-math-3.2.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-math_3.2.0_1735471943081_0.9314307003985938"},"_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":1735471943246,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1735471943246,"dist-tags":{"latest":"5.1.0"}}