@crbroughton/ts-utils
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

ts-utils

A collection of helper functions and types. To use any of the following, simply import into your project like so:

import { handleError, safeAwait } from '@crbroughton/ts-utils'

Installation

To install ts-utils with Bun, run the following command:

bun i -D @crbroughton/ts-utils

await

The await directory contains the following:

  • safeAwait - This function return either a result or error value (think Go)
  • handleError - To be used in conjunction with safeAwait

The goal of the await helpers is to make it more obvious where throw exceptions occur and to help guide the user to write exception handlers. Please inspect the the accompanying test file file to see both helpers in action.

enum

The enum directory contains the following:

  • EnumLike - A helper type to define enum-like objects
  • createEnum - A function to create enum-like object

It is intended that you'll only need to interface with the createEnum function, however the EnumLike type has been exported if you find yourself requiring it.

utils

The utils directory for now only contains the Prettify type, which will improve your experience when hovering over type to get their underlying type information.

Development Installation

bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.1.27. Bun is a fast all-in-one JavaScript runtime.

Package Sidebar

Install

npm i @crbroughton/ts-utils

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

5 kB

Total Files

5

Last publish

Collaborators

  • crbroughton