@await-of/of
v2.4.10
Published
Promise wrapper with some sugar
Downloads
91
Maintainers
Readme
🍡🍭🍬 O F 🍡🍭🍬
Deno version of module - 🍬🦕 DenOf 🍬🦕.
💬 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