Skip to content

Stamp to check all methods of a consumed interface for implementation

Notifications You must be signed in to change notification settings

mdix/interface-check-stamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Interface check stamp for stampit

Why?

When implementing an interface, one would expect that the program, when executed, throws errors if methods are unimplemented. With the current version of stampit (2), this is not the case. When adding this Interface check stamp to your interface, you make sure that your program fails if the methods defined in your interface are not implemented.

How?

On your shell

npm install mdix/interface-check-stamp --save

In your program just compose the interface check stamp into the interface you create:

const InterfaceCheck = require('interface-check-stamp');

const Interface = 
    stampit()
        .compose(InterfaceCheck) // <-- add interface check stamp here
        .methods({someMethod: () => {}});

const Implementation = 
    stampit()
        .compose(Interface)

This will throw an error that 'someMethod' is not implemented which can be fixed by adding the implementation:

// see above for InterfaceCheck & Interface 

const Implementation = 
    stampit()
        .compose(Interface)
        .methods({someMethod: () => { /* someImplementation */ });

Development

With

npm test

you can run the tests. The module resides in index.js. Have fun!

About

Stamp to check all methods of a consumed interface for implementation

Resources

Stars

Watchers

Forks

Packages

No packages published