{"name":"nice-try","version":"4.0.2","keywords":["try","catch","error"],"license":"MIT","_id":"nice-try@4.0.2","maintainers":[{"name":"electerious","email":"tobias@electerious.com"}],"homepage":"https://github.com/electerious/nice-try","bugs":{"url":"https://github.com/electerious/nice-try/issues"},"dist":{"shasum":"a72124313af46354ac81eb8c4f0e06f6b3eb4748","tarball":"http://registry-npm.ywwl.com/nice-try/download/nice-try-4.0.2.tgz","fileCount":5,"integrity":"sha512-dj7jCdOjiF5cDwpXQ243GFofw+8+flZ86U7hcfAJPZ2QrHt+M0+ZTwOjLPTVDHrbM0kolX4M7GIZ7CotI1/Mvw==","signatures":[{"sig":"MEQCIGJMthgvXDszXDp66XPrFiYNX+/JFP06cI6Ffmzqol0PAiAJkgkp3Am9JqXFtWqESmA9yJ9VfkTldT3eo5MARJqBOg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4499,"size":2195,"noattachment":false,"key":"/nice-try/-/nice-try-4.0.2.tgz"},"main":"src/index.js","type":"module","authors":["Tobias Reich <tobias@electerious.com>"],"exports":{".":"./src/index.js","./promises":"./src/promises.js"},"gitHead":"7703946bf968f30e7510493da071a4b83e857b8e","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}'"},"_npmUser":{"name":"electerious","email":"tobias@electerious.com"},"repository":{"url":"git+https://github.com/electerious/nice-try.git","type":"git"},"_npmVersion":"10.9.2","description":"Tries to execute a function and discards any error that occurs","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.33.0","prettier":"^3.6.2","@electerious/eslint-config":"^5.0.0","@electerious/prettier-config":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nice-try_4.0.2_1755347766350_0.6179204934413725","host":"s3://npm-registry-packages-npm-production"},"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":1755347766515,"_cnpm_publish_time":1755347766515,"dist-tags":{"latest":"5.0.0"}}