{"name":"nice-try","version":"4.0.0","keywords":["try","catch","error"],"license":"MIT","_id":"nice-try@4.0.0","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":"c2bddde7826822591b96151dd1c3783062eb0c64","tarball":"http://registry-npm.ywwl.com/nice-try/download/nice-try-4.0.0.tgz","fileCount":5,"integrity":"sha512-KWWGBWPDuuL4OHmYLXWpXRwGDXokNxHdrsROv0W9vKQNk+pAjiqIlLU6FNZnUv9WD2iQUQHYnyGLsLp5TM8EtA==","signatures":[{"sig":"MEUCIQDUyiQGLG1EsR4l6Eg/RqRzYA3IY2vJ3RJwneKlhR7bCQIgXBSyDLnhd2WnDps8vP3lcfNPMml7rhqgoaz6SNtSTPI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4214,"size":2147,"noattachment":false,"key":"/nice-try/-/nice-try-4.0.0.tgz"},"main":"src/index.js","type":"module","authors":["Tobias Reich <tobias@electerious.com>"],"exports":{".":"./src/index.js","./promises":"./src/promises.js"},"gitHead":"c36cc4e23c8a1a126145573ee373e00ae252e4a5","scripts":{"test":"npm run prettier -- --check && node --test","format":"npm run prettier -- --write","prettier":"prettier --ignore-path .gitignore '**/*.{js,json,md}'"},"_npmUser":{"name":"electerious","actor":{"name":"electerious","type":"user","email":"tobias@electerious.com"},"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":"23.7.0","_hasShrinkwrap":false,"devDependencies":{"prettier":"^3.6.2","prettier-plugin-packagejson":"^2.5.18","@ianvs/prettier-plugin-sort-imports":"^4.4.2"},"_npmOperationalInternal":{"tmp":"tmp/nice-try_4.0.0_1751900555363_0.9200868213620039","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":1751900555542,"_cnpm_publish_time":1751900555542,"dist-tags":{"latest":"5.0.0"}}