We have a special on combinators this evening. Why not try a side order?
function explicitize (fn) {
return function () {
return fn.apply(null, p(arguments, this));
}
}
Now you can write: foo.prototype.bar = explicitize(function (myself, something, etc) {
// ...
}that's pretty much what I meant by wrapped in a utility function... generally... something akin to explitize(ConstructorName, 'methodname') .. so that the passthrough call(s) can be shimmed/mocked for testing...
I also tend to prefer methods that accept an object parameter as opposed to using "this" and will often put wrappers on objects such as...
with p being an alias to Array.prototype.shift.apply, put the second arg to the top of the former as an array... it's generally wrapped in a utility function... With that in place my entire prototype's functions are just pass through to static Foo.fn .. in general this makes it easier to test modules that are instance objects.Though prefer to have utility modules over modules that expose an object constructor... Exception being Models, which inherit from EventEmitter2