1.0.1 • Published 7 months ago

promise-split v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months 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.1

7 months ago

1.0.0

7 months ago