util-promise

Methods

(inner) deferred() → {object}

Simpler way of using Promise
Since:
  • 0.0.2
Source:
Example
// return instance
function wait() {
  const d = deferred();

  setTimeout(() => {
    try {
      const value = getMeTheValue();
      d.resolve(value);
    } catch (e) {
      d.reject(e)
    }
  }, 1000);

  return d.promise;
}