# @replygirl/tc

> destructurable, async-friendly `try...catch` wrapper function with support for error side effects and fallback values

Latest version **4.0.2** (published 2022-03-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install @replygirl/tc
pnpm add @replygirl/tc
yarn add @replygirl/tc
bun add @replygirl/tc
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.2 |
| Published | 2022-03-27 |
| First published | 2020-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12.x |
| Dependencies | 0 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | replygirl |
| Maintainers | imogen |
| Keywords | async, await, awaitable, promise, try, catch, wrapper, function, fallback, error handling, destructure, destructuring, functional, utility, helper |

## Links

- npm: https://www.npmjs.com/package/@replygirl/tc
- Repository: https://github.com/replygirl/tc
- Homepage: https://tc.replygirl.club
- Issues: https://github.com/replygirl/tc/issues
- npm.io page: https://npm.io/package/@replygirl/tc

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 4.0.2 (latest) — 2022-03-27
- 4.0.1 — 2021-10-11
- 4.0.0 — 2021-10-03
- 3.0.0 — 2020-12-04
- 2.0.1 — 2020-11-27
- 2.0.0 — 2020-11-27
- 1.1.10 — 2020-11-27
- 1.1.9 — 2020-11-24
- 1.1.8 — 2020-11-24
- 1.1.7 — 2020-11-24
- 1.1.6 — 2020-11-24
- 1.1.5 — 2020-11-23
- 1.1.4 — 2020-11-23
- 1.1.3 — 2020-11-23
- 1.1.2 — 2020-11-23
- … 3 more at https://npm.io/package/@replygirl/tc/versions

## README

# `tc`

![node-current (scoped)](https://img.shields.io/node/v/@replygirl/tc) ![GitHub top language](https://img.shields.io/github/languages/top/replygirl/tc) [![Libraries.io dependency status for latest release, scoped npm package](https://img.shields.io/librariesio/release/npm/@replygirl/tc)](https://libraries.io/npm/@replygirl%2Ftc) [![Maintainability](https://api.codeclimate.com/v1/badges/5b5dd5c4f416e83e89ff/maintainability)](https://codeclimate.com/github/replygirl/tc/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/5b5dd5c4f416e83e89ff/test_coverage)](https://codeclimate.com/github/replygirl/tc/test_coverage) [![GitHub issues](https://img.shields.io/github/issues/replygirl/tc)](https://github.com/replygirl/tc/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/replygirl/tc)](https://github.com/replygirl/tc/pulls)

destructurable, async-friendly `try...catch` wrapper function with support for error side effects and fallback values

## Installation & usage

See the [docs](https://tc.replygirl.club) for full details.

```ts
import tc from '@replygirl/tc'

// get the return value and error of a try callback
const [x, e] = tc(() => { /* ... */ })

// or put complex error handling in a catch callback
const [y] = await tc(doSomething, async e => {
  await reportError(e)
  return getFallbackValue(e)
})

// reuse your error handling by defining your own wrapper
const tce = (t, c) => tc(t, async e => {
  await reportError(e)
  return c(e)
})
const [z] = tce(doSomething, getFallbackValue)
```

---

[ISC License | Copyright © 2020–present replygirl](https://github.com/replygirl/tc/blob/main/LICENSE.md)

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