Deno version of module - π¬π¦ DenOf π¬π¦.
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