Skip to content

keegan-w/promise-split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published