sfcode An Online Competing and Development Environment

Thenable

Thenable object (an object with `then` method)

# <tt>thenable/is</tt>

Confirms if given object is a thenable

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

# <tt>thenable/ensure</tt>

If given argument is a thenable object, it is returned back. Otherwise `TypeError` is thrown.

const ensureThenable = require("type/thenable/ensure");
const promise = Promise.resolve();
ensureThenable(promise); // promise
ensureThenable({}); // Thrown TypeError: [object Object] is not a thenable object