{"name":"@putout/plugin-maybe","version":"5.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@5.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":"30b9376c31234d0ed8ce7a45cf2b98eac5416033","tarball":"http://registry-npm.ywwl.com/@putout/plugin-maybe/download/@putout/plugin-maybe-5.0.0.tgz","fileCount":9,"integrity":"sha512-baVDlmLiJpvTV/bE+DRT6FUqYA/a8RMXWq5DEFPY8BgT21EzFjj6KgzYTAJZVtop0sKOKo7DcS6JrCkReONKFg==","signatures":[{"sig":"MEMCHwormt6+oWP9+RsJn3lyAfx1b0EjnTmkkjb/ugcQ3dQCIFD6PI4W2mBe5NoA4Teev9tACklLZv8izx2rMhgm3ZyY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6786,"size":2660,"noattachment":false,"key":"/@putout/plugin-maybe/-/@putout/plugin-maybe-5.0.0.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=22"},"gitHead":"333194b103b050e3b7bcfb8f26decc7959879050","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.4.2","description":"🐊Putout plugin applies Maybe monad","directories":{},"_nodeVersion":"22.22.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^10.0.0","madrun":"^13.0.0","montag":"^1.2.1","nodemon":"^3.0.1","@putout/test":"^15.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^31.0.0"},"peerDependencies":{"putout":">=42"},"_npmOperationalInternal":{"tmp":"tmp/plugin-maybe_5.0.0_1771450761150_0.4085134464493003","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":1771450761292,"_cnpm_publish_time":1771450761292,"dist-tags":{"latest":"5.1.0"}}