Without default it means that every initializer that wants to access options object has to take care of it on its own. Imagine using stamps in some bigger application with many initializers. Should really each one of them do it again and again?
Frankly it already looks less readable with so much brackets. Initializer has to validate mydata anyway, so why not lift this small burden and give there a little insurance that object will be there if nothing was passed in?
Also if using anonymous fat arrow functions, the stack trace would be actually somewhat unhelpful locating which initializer is actually failing. With named functions it's bit easier, but that heavily depends on how good name has been used.
TypeError: Cannot read property 'mydata' of undefined
at Object.stampit.default.compose.initializers (pen.js:5062:29)
at http://s.codepen.io/boomerang/f4a63016cac103fc2fbac879211b8a111464779436316/index.html:4795:43
at Array.reduce (native)
at Stamp (http://s.codepen.io/boomerang/f4a63016cac103fc2fbac879211b8a111464779436316/index.html:4794:69)
at pen.js:5067:5
In case there is a really need to use something else than a plain object, it's still possible to pass it to factory anyway given that all initializers in the mix can handle that properly. I think it's good to promote the pattern of using options object with this.
Without default it means that every initializer that wants to access options object has to take care of it on its own. Imagine using stamps in some bigger application with many initializers. Should really each one of them do it again and again?
Frankly it already looks less readable with so much brackets. Initializer has to validate
mydata
anyway, so why not lift this small burden and give there a little insurance that object will be there if nothing was passed in?Also if using anonymous fat arrow functions, the stack trace would be actually somewhat unhelpful locating which initializer is actually failing. With named functions it's bit easier, but that heavily depends on how good name has been used.
See the Pen Playground for stampit by Daniel K. (@FredyC) on CodePen.
In case there is a really need to use something else than a plain object, it's still possible to pass it to factory anyway given that all initializers in the mix can handle that properly. I think it's good to promote the pattern of using options object with this.