Popularity
0.3
Growing
Activity
6.8
Growing
5
2
0

Description

Promise wrapper with some sugar

Monthly Downloads: 0
Programming language: JavaScript
Tags: Control Flow     Async     Promise     Wrapper    
Latest version: v1.0.6

OF alternatives and similar libraries

Based on the "Control Flow" category

Do you think we are missing an alternative of OF or a related project?

Add another 'Control Flow' Library

README

OF

๐Ÿก๐Ÿญ๐Ÿฌ Promise wrapper with some sugar ๐Ÿก๐Ÿญ๐Ÿฌ

๐Ÿ—Ž OF Documentation ๐Ÿ—Ž

NPM Version NPM Downloads Build Status Issues

Known Vulnerabilities Dependency Status devDependencies Status

Maintainability Codacy Badge Quality Gate Status

GitHub stars GitHub watchers GitHub followers GitHub forks


If you use this project don't forget to give a โญ star โญ to it on GitHub!


[OF](docs/example.png?raw=true "OF")

๐Ÿš€ Install ๐Ÿš€

npm i @r37r0m0d3l/of

๐Ÿ“ˆ Import ๐Ÿ“ˆ

CommonJS.

const of = require("@r37r0m0d3l/of").default;

ECMAScript Modules.

import { of } from "@r37r0m0d3l/of/es";

Script

UNPKG CDN.

<script src="https://unpkg.com/@r37r0m0d3l/of/dist/of.js"></script>

๐Ÿ’ฌ Usage ๐Ÿ’ฌ

const promise = new Promise((resolve, _reject) => {
  resolve({ data: true });
});
const config = {
  defaults: "๐Ÿคท Default value in case of error",
  error: new Error("๐Ÿ’€ Custom error, replaces promise error"),
  retries: 3, // ๐Ÿ” Third time's a charm
  timeout: 1000, // โฑ๏ธ Delay before timeout error
};
const [result, error] = await of(promise, config); // no error thrown
console.log(result); // { data: true }
console.warn(error); // no error thrown, so it's undefined

๐Ÿ‘€ Discover more ๐Ÿ‘€

  • ๐Ÿ”ŽConsono๐Ÿ”Ž - The most informative and correct variable inspector for JavaScript on the web.

  • ๐Ÿ”ฉLocal Storage Fallback๐Ÿ”ฉ - Universal localStorage fallback.

  • ๐Ÿ”„Publish Subscribe๐Ÿ”„ - JavaScript implementation of the Publish-Subscribe pattern.

  • ๐ŸงฐVicis๐Ÿงฐ - Presentation and transformation layer for data output in RESTful APIs.

Or find useful these tools:

  • ๐ŸงพJSON Sorter๐Ÿงพ - Neat online JSON sorter.