{"_id":"@designdegenerate/perhaps","name":"@designdegenerate/perhaps","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@designdegenerate/perhaps","version":"1.0.0","description":"leave your results up to chance","main":"index.js","scripts":{},"author":{"name":"Amalie Spangenberg","email":"amaliespangenberg@mailbox.org"},"license":"MIT","type":"module","_id":"@designdegenerate/perhaps@1.0.0","gitHead":"4002b8791d7c76c8eb351fc9a920d6a6275278fc","_nodeVersion":"23.5.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-tRDoY9iIGwH4NWGc7j+J88qZ51b1Y2ofNZAWVc1x4F0X3K1HcXoH8Gie4JYN1EXkINwx7VHpcSIcfxSXlXXkvw==","shasum":"18f1f4f78d3ae308e33490f4ab9a2f06f5dab14b","tarball":"https://registry.npmjs.org/@designdegenerate/perhaps/-/perhaps-1.0.0.tgz","fileCount":4,"unpackedSize":3183,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDYZEQWoMlxeDPf1iRCXAssfjRsqt5Q4PoQwfuumVH7rwIhAN+7NWM6gnS+Xp3UlIDeKbEyrPbJkxAWchMLsmOvL0BP"}]},"_npmUser":{"name":"designdegenerate","email":"amaliespangenberg@mailbox.org"},"directories":{},"maintainers":[{"name":"designdegenerate","email":"amaliespangenberg@mailbox.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/perhaps_1.0.0_1736790833739_0.3872723155495268"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-13T17:53:53.660Z","1.0.0":"2025-01-13T17:53:53.917Z","modified":"2025-01-13T17:53:54.162Z"},"maintainers":[{"name":"designdegenerate","email":"amaliespangenberg@mailbox.org"}],"description":"leave your results up to chance","author":{"name":"Amalie Spangenberg","email":"amaliespangenberg@mailbox.org"},"license":"MIT","readme":"# perhaps(Not)\n\nLeave your results up to chance. Tired of implementing things \"the right way?\" ``perhaps()`` and ``perhapsNot()`` are two tiny functions which flip a coin and either return the given input or its opposite depending on which way the coin flips. Coin flips are actually 51:49, and not 50:50 as commonly believed [1], which is why this has been split into two functions. ``Perhaps()`` gives you a 51% chance of returning the given input instead of its opposite, whereas ``perhapsNot()`` gives you a 49% chance of returning the given input instead of its opposite.\n\n## The boring way 😤\n```javascript\nif (user.isAuthenticated()) {\n  return true;\n}\n```\n\n## The exciting way 🤩\n```javascript\nimport { perhaps } from \"perhaps\";\n\nif (user.isAuthenticated()) {\n  return perhaps(true);\n}\n```\n\nThe rules are defined as follows for non-boolean values:\n- If the input is a number, return a ``number`` or a ``NaN``.\n- If the input is a ``NaN``, return a ``NaN`` or a ``1``.\n- If the input is ``null`` or ``undefined``, return null/undefined or an empty ``object``.\n- Otherwise, return the input or ``undefined``.\n\nLicensed under the MIT License.\n\n[1] https://arxiv.org/abs/2310.04153","readmeFilename":"README.md"}