@await-of/of
TypeScript icon, indicating that this package has built-in type declarations

2.4.10 • Public • Published

🍡🍭🍬 O F 🍡🍭🍬

https://of.js.org/

Syntactic sugar for asynchronous functions, promises, generators and synchronous functions.

Deno version of module - 🍬🦕 DenOf 🍬🦕.

NPM Version NPM Downloads GitHub Stars

TypeScript Typings Travis CI

Maintainability Rating LGTM Codacy Badge Snyk

OF

💬 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

🗺️ Discover more

My other projects

Package Sidebar

Install

npm i @await-of/of

Homepage

of.js.org

Weekly Downloads

20

Version

2.4.10

License

MIT

Unpacked Size

84.9 kB

Total Files

10

Last publish

Collaborators

  • r37r0m0d3l