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