# try-nice

> try/catch wrapper

Latest version **4.0.4** (published 2021-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install try-nice
pnpm add try-nice
yarn add try-nice
bun add try-nice
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.4 |
| Published | 2021-01-07 |
| First published | 2019-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | An Duong |
| Maintainers | ahdng |
| Keywords | typescript, npm, try, catch |

## Links

- npm: https://www.npmjs.com/package/try-nice
- Homepage: https://github.com/anduong96/try-nice
- Issues: https://github.com/anduong96/try-nice/issues
- npm.io page: https://npm.io/package/try-nice

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 4.0.4 (latest) — 2021-01-07
- 4.0.3 — 2020-09-19
- 4.0.2 — 2020-09-18
- 4.0.0 — 2020-09-18
- 3.0.0 — 2020-08-19
- 2.1.4 — 2020-06-28
- 2.1.3 — 2020-05-27
- 2.1.2 — 2020-05-27
- 2.1.1 — 2020-05-27
- 2.0.4 — 2019-12-29
- 2.0.3 — 2019-12-29
- 2.0.2 — 2019-12-27
- 2.0.1 — 2019-12-24
- 2.0.0 — 2019-12-24
- 1.1.0 — 2019-12-23
- … 6 more at https://npm.io/package/try-nice/versions

## README

# try-nice

[![build status](https://img.shields.io/travis/com/anduong96/try-nice.svg)](https://travis-ci.com/anduong96/try-nice)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![license](https://img.shields.io/github/license/anduong96/try-nice.svg)](LICENSE)
[![npm downloads](https://img.shields.io/npm/dt/try-nice.svg)](https://npm.im/try-nice)

> Clean try/catch wrapper


## Table of Contents

* [Install](#install)
* [Usage](#usage)
* [Contributors](#contributors)
* [License](#license)


## Install

[npm][]:

```sh
npm install try-nice
```

[yarn][]:

```sh
yarn add try-nice
```


## Usage

```js
var { tryNice } = require('try-nice')

function getOne() {
  return 1
}

var [result] = tryNice(getOne)
// result === 1
```

## Usage ES6

```js
import { tryNice } from 'try-nice'
const [result] = tryNice(() => 1)
//result === 1

const getTwo = async () => 2
const [asyncResult] = await tryNice(getTwo)
// asyncResult === 2

const getValue = async (value) => value
const [parameterizedResult] = await tryNice(getValue, 3)
// parameterizedResult === 3

const getError = async () => {
  throw new Error()
}

const [emptyResult, error] = await tryNice(getError)
// emptyResult === undefined
// error instanceof Error
```

## Usage Typescript
```js
import { tryNice } from 'try-nice'
const [result] = tryNice(() => 1)
//result === 1

const getTwo = async (): number => 2
const [asyncResult] = await tryNice(getTwo)
// asyncResult === 2

const getValue = async (value: string): string  => value
const [parameterizedResult] = await tryNice(getValue, 3)
// parameterizedResult === 3

const getError = async (): void => {
  throw new Error()
}

const [emptyResult, error] = await tryNice(getError)
// emptyResult === undefined
// error instanceof Error
```


## Contributors

| Name         |
| ------------ |
| **An Duong** |


## License

[MIT](LICENSE) © An Duong


##

[npm]: https://www.npmjs.com/

[yarn]: https://yarnpkg.com/

---
_Source: https://npm.io/package/try-nice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
