syncdicate
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i syncdicate

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

1.62 kB

Total Files

4

Last publish

Collaborators

  • mbedna