{"_id":"nice-try@5.0.0","bugs":{"url":"https://github.com/electerious/nice-try/issues"},"dist":{"shasum":"1b6496c6ae458ef63904df5ad2196ad956df3ee9","tarball":"http://registry-npm.ywwl.com/nice-try/download/nice-try-5.0.0.tgz","fileCount":5,"integrity":"sha512-L/GjreRvi00rzyNQc2bnxnvP0o+laAhuVn7AuauX3sZbaL1YKr4ysyH0SX50KtRkbukDacJKTQV7O/Q1/FEOeQ==","signatures":[{"sig":"MEUCIBBHECC8vY/5TodQINodU30IjJvh7CW2f/Z78p1+WabvAiEA5oDuIersNHjTxBH/GVt6d/BNV0kDzUeJBnW8j6kEwL8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAqnR0T9S8E33uJdlhckqYa39l8liG5IzALMfGVUkue7AiEAzt5RVG9XBP3R+UsoG+nLd8gle3wgyGx/9VIySj88+6o="}],"unpackedSize":4593,"size":2213,"noattachment":false,"key":"/nice-try/-/nice-try-5.0.0.tgz"},"main":"src/index.js","name":"nice-try","type":"module","authors":["Tobias Reich <tobias@electerious.com>"],"exports":{".":"./src/index.js","./promises":"./src/promises.js"},"gitHead":"d3b02f858880ac93ceddba8b24a475591684e00b","license":"MIT","scripts":{"lint":"npm run eslint && npm run prettier -- --check","test":"npm run lint && node --test","eslint":"eslint \"**/*.js\"","format":"npm run eslint -- --fix && npm run prettier -- --write","prettier":"prettier --ignore-path .gitignore \"**/*.{js,json,md,yml}\""},"version":"5.0.0","_npmUser":{"name":"electerious","email":"tobias@electerious.com"},"homepage":"https://github.com/electerious/nice-try","keywords":["try","catch","error"],"repository":{"url":"git+https://github.com/electerious/nice-try.git","type":"git"},"_npmVersion":"11.19.1","description":"Tries to execute a function and discards any error that occurs","directories":{},"maintainers":[{"name":"electerious","email":"tobias@electerious.com"}],"_nodeVersion":"26.9.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.8.1","prettier":"^3.6.2","@electerious/eslint-config":"^6.0.0","@electerious/prettier-config":"^5.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nice-try_5.0.0_1791101278046_0.5858428053338913"},"readme":"# nice-try\n\n[![Test](https://github.com/electerious/nice-try/actions/workflows/test.yml/badge.svg)](https://github.com/electerious/nice-try/actions/workflows/test.yml)\n\nA function that tries to execute a function and discards any error that occurs.\n\n## Install\n\n```bash\nnpm install nice-try\n```\n\n## Usage\n\n```js\nimport niceTry from 'nice-try'\n\nniceTry(() => JSON.parse('true')) // true\nniceTry(() => JSON.parse('error')) // undefined\nniceTry() // undefined\nniceTry(true) // undefined\n```\n\n```js\nimport niceTry from 'nice-try/promises'\n\nawait niceTry(async () => JSON.parse('true')) // true\nawait niceTry(async () => JSON.parse('error')) // undefined\n```\n\n## API\n\n### `nice-try`\n\n#### Parameters\n\n- `fn` `{Function}` The function to execute.\n\n#### Returns\n\n- `{any}` The return value of the function, or `undefined` if an error occurred.\n\n### `nice-try/promises`\n\n#### Parameters\n\n- `fn` `{Function}` An asynchronous function to execute.\n\n#### Returns\n\n- `{Promise<any>}` The result of the function if it resolves successfully, otherwise undefined if an error is thrown.\n\n## What others say\n\nThis module is a controversial thing and people like to get mad about it. I decided to give those people a voice. Here's what they're saying.\n\n> fundamentally inane\n\n— frou_dh\n\n> the worst Javascript library […] in several categories\n\n— kuzux\n\n> how is this a thing\n\n— uint8_t\n\n> This is blowing my mind\n\n— mr_jim_lahey\n\n> a shit-tastic try-catch alias\n\n— Dropping_fruits\n\n> I assumed every commit was a joke, but after researching the maintainer a bit I'm not sure it is...\n\n— MrPineappleHat\n","publish_time":1791101278132,"_cnpm_publish_time":1791101278132,"dist-tags":{"latest":"5.0.0"}}