Skip to content

Instantly share code, notes, and snippets.

@mdix
Last active November 17, 2015 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdix/7e1b7358eff5f7ce21eb to your computer and use it in GitHub Desktop.
Save mdix/7e1b7358eff5f7ce21eb to your computer and use it in GitHub Desktop.
Interface check for stampit 2
'use strict';
var stampit = require('stampit');
const MyInterfaceCheckStamp =
stampit()
.init(function(stamp) {
for (var method in stamp.stamp.fixed.methods) {
var currentMethod = stamp.stamp.fixed.methods[method];
if (currentMethod.toString().match(/{[\s\n]*}/g) !== null) {
throw new Error('Method \’' + method.toString() + '\' needs to be implemented.');
}
}
})
const MyInterfaceStamp =
stampit()
.compose(MyInterfaceCheckStamp)
.methods(
{
connect: () => {},
save: function() {}
}
)
const MyImplementationStamp =
stampit()
.compose(MyInterfaceStamp)
.methods(
{
connect: () => {
// implementation
}
}
)
var myImplementationStamp = MyImplementationStamp();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment