Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Last active August 21, 2016 16:49
Show Gist options
  • Select an option

  • Save 1dolinski/9fd428e7f713422cac8d4b6286aa6146 to your computer and use it in GitHub Desktop.

Select an option

Save 1dolinski/9fd428e7f713422cac8d4b6286aa6146 to your computer and use it in GitHub Desktop.
const stampit = require('stampit');
// stampit(methods, state, enclose);
var testObj = stampit(
// methods
{
delegateMethod: function delegateMethod() {
return 'shared property';
}
},
// state
{
instanceProp: 'instance property'
},
// enclose
function () {
var privateProp = 'private property';
this.getPrivate = function getPrivate() {
return privateProp;
}
}).create();
// Why does this return {}?
console.log(testObj); // {}
const stampit = require('stampit');
// this works?
testObj = stampit().state({instanceProp: 'instanceProp'}).create();
console.log(testObj) // {instanceProp: 'instanceProp'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment