Skip to content

peng-yin/tools

Repository files navigation

tools-ts v1

Tool library based on typescript.

## Install
yarn add @pengyin/tools

# npm install @pengyin/tools

Usage

import { to  } from "@pengyin/tools";

interface ServerResponse {
  test: number;
}

const p = Promise.resolve({test: 123});

const [err, data] = await to<ServerResponse>(p);

async function asyncFunctionWithThrow() {
  const [err, user] = await to(UserModel.findById(1));
  if (!user) throw new Error('User not found');
}

feature

  • docs
  • jest

License

MIT License

About

Tool library based on typescript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published