@pengyin/tools
v1.0.7
Published
Tool library based on typscript
Downloads
13
Readme
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