@sweetacid/saw
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

saw

sync/async function wrapper

usage

const doSomething = () => console.log("zzZ..");
const doSomethingAsync = async () => console.log("...zzZ");
const doSomethingWith = (value: number) => console.log(value);
const throwSomething = () => {
    throw new Error("ZZZ");
};

const example = async () => {
    await saw(doSomething);

    await saw(doSomethingAsync);

    await saw(() => doSomethingWith(69));

    const [error] = await saw(throwSomething);
    if (error) {
        console.log("something bad happened");
    }
};

Readme

Keywords

none

Package Sidebar

Install

npm i @sweetacid/saw

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

52.9 kB

Total Files

13

Last publish

Collaborators

  • sweetacid