Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peng-yin/tools
Tool library based on typescript.
https://github.com/peng-yin/tools
Last synced: 19 days ago
JSON representation
Tool library based on typescript.
- Host: GitHub
- URL: https://github.com/peng-yin/tools
- Owner: peng-yin
- License: mit
- Created: 2021-04-17T12:08:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-22T10:59:25.000Z (about 3 years ago)
- Last Synced: 2024-08-09T08:59:22.585Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 329 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tools-ts v1
Tool library based on typescript.![](https://img.shields.io/npm/v/@pengyin/tools)
![](https://img.shields.io/github/license/peng-yin/tools)
![](https://img.shields.io/npm/types/@pengyin/tools)
![](https://img.shields.io/bundlephobia/min/@pengyin/tools)
## Install```sh
yarn add @pengyin/tools# npm install @pengyin/tools
```## Usage
```ts
import { to } from "@pengyin/tools";interface ServerResponse {
test: number;
}const p = Promise.resolve({test: 123});
const [err, data] = await to(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](https://github.com/peng-yin/tools/blob/main/LICENSE)