UNPKG

879 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4/**
5 * See if an object (`val`) is an instance of the supplied constructor. This
6 * function will check up the inheritance chain, if any.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.3.0
11 * @category Type
12 * @sig (* -> {*}) -> a -> Boolean
13 * @param {Object} ctor A constructor
14 * @param {*} val The value to test
15 * @return {Boolean}
16 * @example
17 *
18 * R.is(Object, {}); //=> true
19 * R.is(Number, 1); //=> true
20 * R.is(Object, 1); //=> false
21 * R.is(String, 's'); //=> true
22 * R.is(String, new String('')); //=> true
23 * R.is(Object, new String('')); //=> true
24 * R.is(Object, 's'); //=> false
25 * R.is(Number, {}); //=> false
26 */
27
28
29var is =
30/*#__PURE__*/
31_curry2(function is(Ctor, val) {
32 return val != null && val.constructor === Ctor || val instanceof Ctor;
33});
34
35module.exports = is;
\No newline at end of file