@mono424/interface-js

0.0.2 • Public • Published

InterfaceJs

Just a simple helper to create a self-checking constructor function

Get started

Install from npm

npm --save install @mono424/interface-js

Use :)

const interface = require('./interface');

// Create a interface constructor
const PrintInterface = interface.create([
    ["print", interface.TYPE.Function]
]);

// Create Class implementing the interface
class Foo extends PrintInterface {
    constructor() {
        super();
    }
    
    print() {
        console.log("Bar");
    }
}

// If you create an Item of the class it will check it
const item = new Foo();

/@mono424/interface-js/

    Package Sidebar

    Install

    npm i @mono424/interface-js

    Weekly Downloads

    3

    Version

    0.0.2

    License

    WTFPL

    Unpacked Size

    4.91 kB

    Total Files

    5

    Last publish

    Collaborators

    • mono424