{"name":"@putout/plugin-maybe","version":"3.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin applies Maybe monad","homepage":"https://github.com/coderaiser/maybe/tree/master/packages/plugin-maybe#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git+https://github.com/coderaiser/maybe.git"},"scripts":{"wisdom":"madrun wisdom","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-plugin","putout","plugin","maybe"],"devDependencies":{"@putout/eslint-flat":"^2.0.0","@putout/test":"^11.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^24.0.0","lerna":"^6.0.1","madrun":"^10.0.0","montag":"^1.2.1","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=38"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-maybe@3.0.0","gitHead":"a58669ede4956ce7ba5e79c9ddaefb343af38293","bugs":{"url":"https://github.com/coderaiser/maybe/issues"},"_nodeVersion":"22.14.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-9dQxRA46OxAxOifWGdYUF7Oru7pbHKRb4LMZbA42LUbTsa6Pthc5TisTaHAY6eX3OiIN097HomhWjyryeM4oyQ==","shasum":"fb5e2036c4493fdf768898ae74c783db3fd088b5","tarball":"http://registry-npm.ywwl.com/@putout/plugin-maybe/download/@putout/plugin-maybe-3.0.0.tgz","fileCount":9,"unpackedSize":6694,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEmhBiXqPoMHW+tMPfy2LUTqS7FboqpoUNolugwZ3mI6AiEAtAAuXtqypQGaCW4SGJ6w0PaVsEipzB6m5qTl+HfEgTo="}],"size":2623,"noattachment":false,"key":"/@putout/plugin-maybe/-/@putout/plugin-maybe-3.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-maybe_3.0.0_1739623042164_0.8262245064438631"},"_hasShrinkwrap":false,"readme":"# @putout/plugin-maybe [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-maybe.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-maybe \"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps with `maybe` monad.\n\n## Install\n\n```\nnpm i @putout/plugin-maybe -D\n```\n\n## Rules\n\n- ✅ [array](#array);\n- ✅ [empty-array](#empty-array);\n- ✅ [fn](#fn);\n- ✅ [noop](#noop);\n- ✅ [declare](#declare);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"maybe/array\": \"on\",\n        \"maybe/empty-array\": \"on\",\n        \"maybe/fn\": \"on\",\n        \"maybe/noop\": \"on\",\n        \"maybe/declare\": \"on\"\n    }\n}\n```\n\n## array\n\n### ❌ Example of incorrect code\n\n```js\nconst {isArray} = Array;\nconst array = isArray(a) ? a : [a];\n```\n\n### ✅ Example of correct code\n\n```js\nconst {isArray} = Array;\nconst maybeArray = (a) => isArray(a) ? a : [a];\nconst array = maybeArray(a);\n```\n\n## empty-array\n\n### ❌ Example of incorrect code\n\n```js\nconst array = !a ? [] : a;\n```\n\n### ✅ Example of correct code\n\n```js\nconst maybeArray = (a) => !a ? [] : a;\nconst array = maybeEmptyArray(a);\n```\n\n## fn\n\n### ❌ Example of incorrect code\n\n```js\nconst isFn = (a) => typeof a === 'function';\nconst fn = isFn(a) ? a : () => {};\n```\n\n### ✅ Example of correct code\n\n```js\nconst isFn = (a) => typeof a === 'function';\nconst noop = () => {};\nconst maybeFn = isFn(a) ? a : noop;\nconst fn = maybeFn(a);\n```\n\n## noop\n\n### ❌ Example of incorrect code\n\n```js\nconst fn = f || (() => {});\n```\n\n### ✅ Example of correct code\n\n```js\nconst noop = () => {};\nconst fn = fn || noop;\n```\n\n## declare\n\n### ❌ Example of incorrect code\n\nWhen you not sure is `f` a function, but you want to use it as function anyways:\n\n```js\nconst fn = maybeFn(f);\n\nmaybeCall(fn);\n```\n\n### ✅ Example of correct code\n\n```js\nconst isFn = (a) => typeof a === 'function';\nconst noop = () => {};\nconst maybeFn = (a) => isFn(a) ? a : noop;\nconst maybeCall = (a, ...b) => isFn(a) && a(...b);\n\nconst fn = maybeFn(f);\nmaybeCall(fn);\n```\n\nWhen you not sure is `a` is an array or not, but you want to get first element of it.\n\n### ❌ Example of incorrect code\n\n```js\nconst b = maybeFirst(a);\n```\n\n### ✅ Example of correct code\n\n```js\nconst {isArray} = Array;\nconst maybeFirst = (a) => isArray(a) ? a[0] : a;\n\nconst b = maybeFirst(a);\n```\n\n## License\n\nMIT\n","publish_time":1739623042352,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1739623042352,"dist-tags":{"latest":"5.1.0"}}