1.0.2 • Published 1 year ago

promise-split v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

promise-split

promise-split is simple utility that allows you to write cleaner code when working with async/await. Skip the need to wrap await inside a try/catch block.

Usage

import fs from 'fs';
import split from 'promise-split';

const readWithPromiseSplit = async (path) => {
    const [file, error] = await split(fs.promises.readFile(path));

    if (error) {
        // Handle errors here
        return 'Failed to read file';
    }

    return file;
}
1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago