Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 589 Bytes

promise.md

File metadata and controls

27 lines (18 loc) · 589 Bytes

Promise

Promise instance

promise/is

Confirms if given object is a native promise

const isPromise = require("type/promise/is");

isPromise(Promise.resolve()); // true
isPromise({ then: () => {} }); // false
isPromise({}); // false

promise/ensure

If given argument is a promise, it is returned back. Otherwise TypeError is thrown.

const ensurePromise = require("type/promise/ensure");

const promise = Promise.resolve();
ensurePromise(promise); // promise
eensurePromise({}); // Thrown TypeError: [object Object] is not a promise