1.1.8 • Published 6 months ago

fast-defer v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Issues Stars License Codecov FOSSA Status Join the chat at https://gitter.im/tinylibs-js-org/community Speed Blazing

Latest Version Downloads JsDelivr Bundlephobia Packagephobia

Table of Contents

Installing

Node

npm install fast-defer # or yarn add fast-defer
const { deferred } = require('fast-defer');
import { deferred } from 'fast-defer';

Browser

<script
  crossorigin
  src="https://cdn.jsdelivr.net/npm/fast-defer@latest/dist/index.umd.js"
></script>
const { deferred } = window.fastDefer;

Url Import

import { deferred } from 'https://cdn.skypack.dev/fast-defer@latest';

Getting Started

A deferred is nothing more than a promise with .resolve() and a .reject() method. You can use it to create a promise that will be resolved or rejected at some point in the future and, probably, in another scope.

import { deferred, isDeferred } from 'fast-defer';

const waitingSomething = deferred();

waitingSomething.then((val) => {
  console.log('Resolved');
});

waitingSomething.catch((error) => {
  console.log('Rejected');
});

// Other file, function or etc
someCallback((response, error) => {
  if (error) {
    waitingSomething.reject(error);
  } else {
    waitingSomething.resolve(response);
  }
});

Browser Compatibility

ChromeEdgeFirefoxInternet ExplorerOperaSafariNode.jsDenoWebView AndroidChrome AndroidFirefox for AndroidOpera AndroidSafari on iOSSamsung Internet
Promise() constructor321229*X1980.121.04.4.33229*198*2.0
Symbol() constructor381236X2590.121.03838362593.0

License

Licensed under the MIT. See LICENSE for more informations.

FOSSA Status

1.1.8

6 months ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago