source: node_modules/ramda/es/is.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: 999 bytes
RevLine 
[d24f17c]1import _curry2 from "./internal/_curry2.js";
2/**
3 * See if an object (i.e. `val`) is an instance of the supplied constructor. This
4 * function will check up the inheritance chain, if any.
5 * If `val` was created using `Object.create`, `R.is(Object, val) === true`.
6 *
7 * @func
8 * @memberOf R
9 * @since v0.3.0
10 * @category Type
11 * @sig (* -> {*}) -> a -> Boolean
12 * @param {Object} ctor A constructor
13 * @param {*} val The value to test
14 * @return {Boolean}
15 * @example
16 *
17 * R.is(Object, {}); //=> true
18 * R.is(Number, 1); //=> true
19 * R.is(Object, 1); //=> false
20 * R.is(String, 's'); //=> true
21 * R.is(String, new String('')); //=> true
22 * R.is(Object, new String('')); //=> true
23 * R.is(Object, 's'); //=> false
24 * R.is(Number, {}); //=> false
25 */
26
27var is =
28/*#__PURE__*/
29_curry2(function is(Ctor, val) {
30 return val instanceof Ctor || val != null && (val.constructor === Ctor || Ctor.name === 'Object' && typeof val === 'object');
31});
32
33export default is;
Note: See TracBrowser for help on using the repository browser.