1.0.0 • Published 5 years ago

implemented v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Implements

A simple javascript module for checking interface implementations.

Usage

Require

const implem = require('implements');

implem is an object with the following properties:

PropertyDescription
checkImplementation(interface, implementation)Check if interface is implemented, otherwise throws an error.
PropertyA class that represent a property of an implementation

Property

The constructor has the following signature Property(type, args)

ParameterTypeDescription
typestringThe js primitive type of the property
argsnumberIf type is 'function' indicates the function number of arguments, otherwise is ignored

Example

const implem = require('implemented');

const Property = implem.Property;

const interf = {
    prop1: new Property('function', 3),
    prop2: new Property('string'),
    // ...
}

const obj = {};
implem.checkImplementation(interf, obj); // throws an error indicating the missing properties