npm install es6-interface --save
lets jump to some examples
first we start with a simple 1 interface implementation
const Interface = require('es6-interface')
const testInterface1 = new Set(['required1(arg1)']); // required1 is the method we force to implement
class testClass extends Interface(testInterface1) {
constructor() {
super()
}
}
new testClass() // now we will get an error that we need to implement required1(arg1) method
const Interface = require('es6-interface');
const testInterface1 = new Set(['required1(arg1)']);
const testInterface2 = new Set(['required2(arg1,arg2)', 'required3({arg1 , arg2 , arg3})']);
class testClass extends Interface(testInterface1,testInterface2) {
constructor() {
super()
}
}
new testClass() // now we will get an error that we need to implement required1(arg1) required2(arg1,arg2) required3({arg1,arg2,arg3}) methods
const Interface = require('es6-interface');
const testInterface1 = new Set(['required1(arg1)']);
const testInterface2 = new Set(['required2(arg1,arg2)', 'required3({arg1 , arg2 , arg3})']);
const testInterface4 = new Set(['required4({arg1, arg2, arg3}, arg4)']);
class parentClass {
constructor() {
}
required4({arg1, arg2, arg3}, arg4) {
}
}
class testClass extends Interface(testInterface1,testInterface2,testInterface4,parentClass) {
constructor() {
super()
}
}
new testClass() // we will still get an error for no implement required1(arg1) required2(arg1,arg2) required3({arg1,arg2,arg3}) methods as we get required4 from our parent class
- improve performance
- better error messages
npm test