An Interface Class for Javascript
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
interface.js

README.md

Javascript-Interface

An Interface Class for Javascript

Usage

var Composite = new Interface('Composite', ['add', 'remove', 'getChild']);
var FormItem = new Interface('FormItem', ['save']);

// Composite Class

var CompositeForm = function (id, method, action) { // implements Composite, FormItem
  ...
};

...

function addForm (formInstance) {
  Interface.ensureImplements(formInstance, Composite, FormItem);
  // This function will throw an error if a required method is not implemented,
  // halting execution of the function.
  // All code beneath this line will be executed only if the checks pass.
  ...
}