source: node_modules/ramda-adjunct/es/isPrototypeOf.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: 1.1 KB
Line 
1import { curry } from 'ramda';
2import invokeArgs from './invokeArgs';
3
4/**
5 * Checks if an object exists in another object's prototype chain.
6 *
7 * @func isPrototypeOf
8 * @category Object
9 * @memberOf RA
10 * @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
11 * @sig * -> Boolean
12 * @param {Object} type The prototype that we're searching for
13 * @param {Object} object The object whose prototype chain will be searched
14 * @return {boolean}
15 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf|Object.prorotype.isPrototypeOf}
16 * @example
17 * function Foo() {}
18 * function Bar() {}
19 * function Baz() {}
20 *
21 * Bar.prototype = Object.create(Foo.prototype);
22 * Baz.prototype = Object.create(Bar.prototype);
23 *
24 * const baz = new Baz();
25 *
26 * RA.isPrototypeOf(Baz, baz); // => true
27 * RA.isPrototypeOf(Bar, baz); // => true
28 * RA.isPrototypeOf(Foo, baz); // => true
29 * RA.isPrototypeOf(Object, baz); // => true
30 */
31var isPrototypeOf = curry(function (type, object) {
32 return Boolean(invokeArgs(['prototype', 'isPrototypeOf'], [object], type));
33});
34export default isPrototypeOf;
Note: See TracBrowser for help on using the repository browser.