sfcode An Online Competing and Development Environment

Promise

Promise instance

# <tt>promise/is</tt>

Confirms if given object is a native promise

const isPromise = require("type/promise/is");
isPromise(Promise.resolve()); // true
isPromise({ then: () => {} }); // false
isPromise({}); // false

# <tt>promise/ensure</tt>

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