source: node_modules/ramda-adjunct/src/isThenable.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: 796 bytes
RevLine 
[d24f17c]1import { pathSatisfies } from 'ramda';
2
3import isFunction from './isFunction';
4
5/**
6 * Checks if input value is a `thenable`.
7 * `thenable` is an object or function that defines a `then` method.
8 *
9 * @func isThenable
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 RA.isPromise|isPromise}
17 * @example
18 *
19 * RA.isThenable(null); // => false
20 * RA.isThenable(undefined); // => false
21 * RA.isThenable([]); // => false
22 * RA.isThenable(Promise.resolve()); // => true
23 * RA.isThenable(Promise.reject()); // => true
24 * RA.isThenable({ then: () => 1 }); // => true
25 */
26const isThenable = pathSatisfies(isFunction, ['then']);
27
28export default isThenable;
Note: See TracBrowser for help on using the repository browser.