# tcts

> 🤿 functional try ... catch implementation

Latest version **0.0.16** (published 2024-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install tcts
pnpm add tcts
yarn add tcts
bun add tcts
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.16 |
| Published | 2024-09-25 |
| First published | 2023-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 67 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | weltmx |
| Maintainers | weltmx |

## Links

- npm: https://www.npmjs.com/package/tcts
- Repository: https://github.com/weltmx/tcts
- Homepage: http://101.lu
- Issues: https://github.com/weltmx/tcts/issues
- npm.io page: https://npm.io/package/tcts

## Dependencies (67)

- [ms](https://npm.io/package/ms.md) ^2.1.2
- [ajv](https://npm.io/package/ajv.md) ^6.12.6
- [has](https://npm.io/package/has.md) ^1.0.3
- [jju](https://npm.io/package/jju.md) ^1.4.0
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [delay](https://npm.io/package/delay.md) ^6.0.0
- [fastq](https://npm.io/package/fastq.md) ^1.15.0
- [braces](https://npm.io/package/braces.md) ^3.0.2
- [colors](https://npm.io/package/colors.md) ^1.2.5
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [merge2](https://npm.io/package/merge2.md) ^1.4.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [nanoid](https://npm.io/package/nanoid.md) ^3.3.6
- [rollup](https://npm.io/package/rollup.md) ^3.20.2
- [semver](https://npm.io/package/semver.md) ^7.3.8
- [uri-js](https://npm.io/package/uri-js.md) ^4.4.1
- [esbuild](https://npm.io/package/esbuild.md) ^0.17.14
- [is-glob](https://npm.io/package/is-glob.md) ^4.0.3
- [postcss](https://npm.io/package/postcss.md) ^8.4.21
- [resolve](https://npm.io/package/resolve.md) ^1.22.1
- [reusify](https://npm.io/package/reusify.md) ^1.0.4
- [yallist](https://npm.io/package/yallist.md) ^4.0.0
- [argparse](https://npm.io/package/argparse.md) ^1.0.10
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [jsonfile](https://npm.io/package/jsonfile.md) ^6.1.0
- [kolorist](https://npm.io/package/kolorist.md) ^1.7.0
- [punycode](https://npm.io/package/punycode.md) ^2.3.0
- [ts-morph](https://npm.io/package/ts-morph.md) ^17.0.1
- [z-schema](https://npm.io/package/z-schema.md) ^5.0.5
- [commander](https://npm.io/package/commander.md) ^9.5.0
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.12
- [is-number](https://npm.io/package/is-number.md) ^7.0.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^6.0.0
- [minimatch](https://npm.io/package/minimatch.md) ^5.1.6
- [picomatch](https://npm.io/package/picomatch.md) ^2.3.1
- [validator](https://npm.io/package/validator.md) ^13.9.0
- [fill-range](https://npm.io/package/fill-range.md) ^7.0.1
- [is-extglob](https://npm.io/package/is-extglob.md) ^2.1.1
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [micromatch](https://npm.io/package/micromatch.md) ^4.0.5
- [path-parse](https://npm.io/package/path-parse.md) ^1.0.7
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0
- [source-map](https://npm.io/package/source-map.md) ^0.6.1
- [sprintf-js](https://npm.io/package/sprintf-js.md) ^1.0.3
- [glob-parent](https://npm.io/package/glob-parent.md) ^5.1.2
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.11
- [import-lazy](https://npm.io/package/import-lazy.md) ^4.0.0
- [string-argv](https://npm.io/package/string-argv.md) ^0.3.1
- [magic-string](https://npm.io/package/magic-string.md) ^0.29.0
- [run-parallel](https://npm.io/package/run-parallel.md) ^1.2.0
- [universalify](https://npm.io/package/universalify.md) ^2.0.0
- [estree-walker](https://npm.io/package/estree-walker.md) ^2.0.2
- [function-bind](https://npm.io/package/function-bind.md) ^1.1.1
- [source-map-js](https://npm.io/package/source-map-js.md) ^1.0.2
- [balanced-match](https://npm.io/package/balanced-match.md) ^1.0.2
- [is-core-module](https://npm.io/package/is-core-module.md) ^2.11.0
- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.5.0
- [to-regex-range](https://npm.io/package/to-regex-range.md) ^5.0.1
- [brace-expansion](https://npm.io/package/brace-expansion.md) ^2.0.1
- [fast-deep-equal](https://npm.io/package/fast-deep-equal.md) ^3.1.3
- [path-browserify](https://npm.io/package/path-browserify.md) ^1.0.1
- [queue-microtask](https://npm.io/package/queue-microtask.md) ^1.2.3
- [code-block-writer](https://npm.io/package/code-block-writer.md) ^11.0.3
- [strip-json-comments](https://npm.io/package/strip-json-comments.md) ^3.1.1
- [json-schema-traverse](https://npm.io/package/json-schema-traverse.md) ^0.4.1
- [fast-json-stable-stringify](https://npm.io/package/fast-json-stable-stringify.md) ^2.1.0
- [supports-preserve-symlinks-flag](https://npm.io/package/supports-preserve-symlinks-flag.md) ^1.0.0

## Recent versions

- 0.0.16 (latest) — 2024-09-25
- 0.0.15 — 2024-05-27
- 0.0.14 — 2024-03-05
- 0.0.13 — 2024-03-05
- 0.0.12 — 2023-12-04
- 0.0.11 — 2023-06-30
- 0.0.10 — 2023-06-30
- 0.0.9 — 2023-06-29
- 0.0.8 — 2023-06-29
- 0.0.7 — 2023-06-06
- 0.0.6 — 2023-06-02
- 0.0.5 — 2023-06-02
- 0.0.4 — 2023-06-02
- 0.0.3 — 2023-06-01
- 0.0.2 — 2023-06-01
- … 1 more at https://npm.io/package/tcts/versions

## README

# tcts 🤿

Dead simple, functional, curriable try ... catch implementation.

## Install

```bash
npm i tcts
```

## Usage

#### TC - Try catch

```ts
import { tc } from 'tcts'

const [error, value] = tc(() => {
  // errorable code
  return value
})

// use atc for an async try catch
atc(async () => ..)
```

#### TCF - Try catch fallback

```ts
import { tcf } from 'tcts'

const safeParseNum = tcf(0, parseNum)

// partial application to reuse
const tcNumber = tcf(0)
const tcAction = tcf({ error: true })
```

##### Safely access deeply nested objects using tcf

```ts
const translation = tcf("No translation", (t) => t.a.b.c)(translations)
```


##### TCF helpers

```ts
// other helpers

import { tcNull, tcNullish, tcNumber, tcRetry } from 'tcts'

tcNull(fn) // tcf(null, fn)
tcNullish(fn) // tcf(undefined, fn)
tcNumber(fn) // tcf(0, fn)
tcRetry(fn) // tcf(fn, fn)
```

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