{"name":"@putout/plugin-maybe","version":"4.0.0","keywords":["putout-plugin","putout","plugin","maybe"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-maybe@4.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/maybe/tree/master/packages/plugin-maybe#readme","bugs":{"url":"https://github.com/coderaiser/maybe/issues"},"tag":false,"dist":{"shasum":"e820d070d7233aa287cdb867ed7d6911b33e09bd","tarball":"http://registry-npm.ywwl.com/@putout/plugin-maybe/download/@putout/plugin-maybe-4.0.0.tgz","fileCount":9,"integrity":"sha512-SCdZ9p/hA+rw90iMAWJf1W+Eih7DdKpgoiOlaqRjfcrp/igwodzVUYpVKHOlAHmxUSBs1qMXWSO1qLoH4PJZEw==","signatures":[{"sig":"MEUCIFKUmLEu43W6W41qq1HWypeZ1ma7b6vrFQv/s+q1/RWFAiEAh6nPMdMQ7mC8fbQ7hYyQ5XWRGAy7StFJJXkq2L1qe4s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6553,"size":2603,"noattachment":false,"key":"/@putout/plugin-maybe/-/@putout/plugin-maybe-4.0.0.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=20"},"gitHead":"ceb339fa72d6e7cf54222ddb4d6acf23aa431404","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","wisdom":"madrun wisdom","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/maybe.git","type":"git"},"_npmVersion":"11.1.0","description":"🐊Putout plugin applies Maybe monad","directories":{},"_nodeVersion":"22.14.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^9.0.0","madrun":"^11.0.0","montag":"^1.2.1","nodemon":"^3.0.1","@putout/test":"^13.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^26.0.0"},"peerDependencies":{"putout":">=39"},"_npmOperationalInternal":{"tmp":"tmp/plugin-maybe_4.0.0_1743685624593_0.6916165215358596","host":"s3://npm-registry-packages-npm-production"},"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\nDeclares:\n\n- ✅ `maybeArray`;\n- ✅ `maybeEmptyArray`;\n- ✅ `maybeArrayFrom`;\n- ✅ `maybeFn`;\n- ✅ `maybeFirst`;\n- ✅ `maybeCall`;\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":1743685624831,"_cnpm_publish_time":1743685624831,"dist-tags":{"latest":"5.1.0"}}