@cover-slide/defer

1.0.0 • Public • Published

defer

A simple deferred object using native promises

Usage

const db = require(...);
const defer = require('@coverslide/defer');

const deferred = defer();
const something = {};

async function getValue () {
  await deferred.promise;
  console.log(something.value);
}

async function loadValue () {
  const value = await db.get(query);
  something.value = value;
  deferred.resolve();
}

loadValue();
getValue();

Readme

Keywords

none

Package Sidebar

Install

npm i @cover-slide/defer

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • coverslide