lodash-contrib
Version:
The brass buckles on lodash's utility belt
30 lines (21 loc) • 533 B
JavaScript
module.exports = function (_) {
// Helpers
// -------
// Mixing in the truthiness
// ------------------------
_.mixin({
done: function(value) {
var ret = _(value);
ret.stopTrampoline = true;
return ret;
},
trampoline: function(fun /*, args */) {
var result = fun.apply(fun, _.rest(arguments));
while (_.isFunction(result)) {
result = result();
if ((result instanceof _) && (result.stopTrampoline)) break;
}
return result.value();
}
});
};