Syncditace
Small utility function to prevent error throwing from async functions.
Suppress errors
Instead of this:
let file;
try {
file = await fs.promises.readFile('path/to/file.txt');
} catch (err) { }
if (file) {
// Do something with result ...
}
You can do this:
import { $ } from 'syncditace';
let [ file ] = await $(fs.promises.readFile('path/to/file.txt'));
if (file) {
// Do something with result ...
}
Error handling only
import { $ } from 'syncditace';
let [ _, err ] = await $(fs.promises.writeFile('path/to/file.txt'));
if (err) {
// Handle error ...
}