Natural Potato Magnet

    is-prototype-of-x

    2.1.2 • Public • Published

    Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

    is-prototype-of-x

    Checks if an object exists in another object's prototype chain.

    module.exports(proto, object)boolean

    This method checks if an object exists in another object's prototype chain.

    Kind: Exported function
    Returns: boolean - Does the proto object lay in the prototype chain of object.
    Throws:

    • TypeError If proto is undefined or null.
    Param Type Description
    proto Object The proto object to search for.
    object Object The object whose prototype chain will be searched.

    Example

    import isPrototypeOf from 'is-prototype-of-x';
     
    function Foo() {}
    function Bar() {}
    function Baz() {}
     
    Bar.prototype = Object.create(Foo.prototype);
    Baz.prototype = Object.create(Bar.prototype);
     
    const baz = new Baz();
     
    console.log(isPrototypeOf(Baz.prototype, baz)); // true
    console.log(isPrototypeOf(Bar.prototype, baz)); // true
    console.log(isPrototypeOf(Foo.prototype, baz)); // true
    console.log(isPrototypeOf(Object.prototype, baz)); // true

    Install

    npm i is-prototype-of-x

    DownloadsWeekly Downloads

    3

    Version

    2.1.2

    License

    MIT

    Unpacked Size

    41.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • xotic750