🍡 🍭 🍬 O F 🍡 🍭 🍬
Syntactic sugar for asynchronous functions, promises, generators and synchronous functions.
Deno version of module -
💬 Usage
import { ofAnyCase } from "@await-of/of";
const promise = () => new Promise((resolve, _reject) => {
resolve({ data: true });
});
const config = {
defaults: "🤷 Default value in case of error",
error: new Error("💀 Custom error, replaces thrown error"),
retries: 3, // 🔁 Third time's a charm
timeout: 1000, // ⏱️ Delay before timeout error
};
// no error thrown
const [result, error] = await ofAnyCase(promise(), config);
console.log(result); // { data: true }
console.warn(error); // no error thrown, so it's undefined