🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

extend-interface

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extend-interface

extend-interface ================

1.0.1
latest
npm
Version published
Weekly downloads
8
60%
Maintainers
1
Weekly downloads
 
Created
Source

extend-interface

An ultra-lightweight prototypal inheritance mechanism built into the class definition itself.

Usage

    const extendClass = require('extend-interface');

    let MyClass = function(){ }

    MyClass.prototype.output = function(){
        console.log(this.value())
    };
    MyClass.prototype.value = function(){
        throw new Error('No value() implementation')
    };
    MyClass.extend = function(cls, cns){
        var cons = cns || function(){
            MyClass.apply(this, arguments);
            return this;
        };
        return extendClass(cls, cons, MyClass);
    };

then, in another class, you can implement:

    const extendClass = require('extend-interface');

    let SubClass = MyClass.extend({
        value : function(){
            return 'awesome';
        }
    })
    let subClassInstance = new SubClass();

FAQs

Package last updated on 22 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts