1.0.1 • Published 7 months ago
promise-split v1.0.1
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;
}