@ganuz/find-prototype-of
v0.1.1
Published
Find Prototype Of is package from Ganuz library
Downloads
12
Maintainers
Readme
@ganuz/find-prototype-of
Find Prototype Of is package from Ganuz library
Install
$ yarn add @ganuz/find-prototype-of
Or
$ npm install --save @ganuz/find-prototype-of
Use
Module
import {
default as findPrototypeOf
} from '@ganuz/find-prototype-of';
Browser
<script src="https://unpkg.com/@ganuz/find-prototype-of/bundle.umd.min.js"></script>
let {
findPrototypeOf
} = G;
Examples
findPrototypeOf(null, proto => proto); // throw TypeError
findPrototypeOf({}, proto => proto); // => null
findPrototypeOf({foo: 'bar', [Symbol.toStringTag]: 'Foo'}, proto => proto.foo); // => Foo{foo: 'bar'}
findPrototypeOf(function (){}, proto => proto.hasOwnProperty('hasOwnProperty')); // => Object.prototype
let a = Object.create(null, {color: {value: 'red'}});
let b = Object.create(a, {color: {value: 'blue'}});
let c = Object.create(b, {color: {value: 'green'}});
findPrototypeOf(c, (proto) => proto.color === 'blue') === b; // => true
findPrototypeOf(c, (proto) => proto.color === 'pink'); // => null
findPrototypeOf(c, (proto) => console.log(`color: ${proto.color}`));
// => 'color: green'
// => 'color: blue'
// => 'color: red'
// => null
License
Copyright © Yisrael Eliev, Licensed under the MIT license.