> For the complete documentation index, see [llms.txt](https://musicq.gitbook.io/unwrapit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://musicq.gitbook.io/unwrapit/apis/unwrap.md).

# unwrap

```typescript
<T>(opt?: WrapOption) => T | never
```

Try to get the value, will panic when the wrapped value is an error.

```ts
const wrapper = await wrap(Promise.resolve(1))
const json = wrapper.unwrap() // 1
```

In Node.js, you can specify `{panic: true}` to let the program exit instead of throwing an error.

```ts
// this will exit the program in Node.js
(await wrap(Promise.reject(1))).unwrap({panic: true})
```

{% hint style="info" %}
If you want to enable panic always in Node.js, you can specify the `panic` option in [`WrapConfig`](/unwrapit/apis/definewrapconfig.md).
{% endhint %}

### Exit code

If you need to specify an exit code in Node.js, you can pass the `exitCode` to `unwrap` method.

```typescript
(await wrap(Promise.reject(1))).unwrap({panic: true, exitCode: 2})
```
