source: node_modules/ramda-adjunct/es/isPromise.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 942 bytes
Line 
1import { both, pipe, toString, equals, curryN } from 'ramda';
2import isObj from './isObj';
3
4/**
5 * Checks if input value is a native `Promise`.
6 * The Promise object represents the eventual completion (or failure)
7 * of an asynchronous operation, and its resulting value.
8 *
9 * @func isPromise
10 * @memberOf RA
11 * @since {@link https://char0n.github.io/ramda-adjunct/2.1.0|v2.1.0}
12 * @category Type
13 * @sig * -> Boolean
14 * @param {*} val The value to test
15 * @return {boolean}
16 * @see {@link https://promisesaplus.com/|Promises/A+}, {@link RA.isThenable|isThenable}
17 * @example
18 *
19 * RA.isPromise(null); // => false
20 * RA.isPromise(undefined); // => false
21 * RA.isPromise([]); // => false
22 * RA.isPromise(Promise.resolve()); // => true
23 * RA.isPromise(Promise.reject()); // => true
24 * RA.isPromise({ then: () => 1 }); // => false
25 */
26var isPromise = curryN(1, both(isObj, pipe(toString, equals('[object Promise]'))));
27export default isPromise;
Note: See TracBrowser for help on using the repository browser.