ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
31 lines (30 loc) • 1.19 kB
JavaScript
exports.__esModule = true;
exports["default"] = void 0;
var _ramda = require("ramda");
var _isObj = _interopRequireDefault(require("./isObj.js"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
* Checks if input value is a native `Promise`.
* The Promise object represents the eventual completion (or failure)
* of an asynchronous operation, and its resulting value.
*
* @func isPromise
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/2.1.0|v2.1.0}
* @category Type
* @sig * -> Boolean
* @param {*} val The value to test
* @return {boolean}
* @see {@link https://promisesaplus.com/|Promises/A+}, {@link RA.isThenable|isThenable}
* @example
*
* RA.isPromise(null); // => false
* RA.isPromise(undefined); // => false
* RA.isPromise([]); // => false
* RA.isPromise(Promise.resolve()); // => true
* RA.isPromise(Promise.reject()); // => true
* RA.isPromise({ then: () => 1 }); // => false
*/
var isPromise = (0, _ramda.curryN)(1, (0, _ramda.both)(_isObj["default"], (0, _ramda.pipe)(_ramda.toString, (0, _ramda.equals)('[object Promise]'))));
var _default = exports["default"] = isPromise;
;