@ganuz/find-prototype-of
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@ganuz/find-prototype-of

Source Code Version MIT License Bundle Size TypeScript

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.

Package Sidebar

Install

npm i @ganuz/find-prototype-of

Weekly Downloads

2

Version

0.1.1

License

MIT

Unpacked Size

60.8 kB

Total Files

15

Last publish

Collaborators

  • yisraelx