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