mixin.js 577 B

12345678910111213141516171819
  1. define(['./underscore', './each', './functions', './_setup', './_chainResult'], function (underscore, each, functions, _setup, _chainResult) {
  2. // Add your own custom functions to the Underscore object.
  3. function mixin(obj) {
  4. each(functions(obj), function(name) {
  5. var func = underscore[name] = obj[name];
  6. underscore.prototype[name] = function() {
  7. var args = [this._wrapped];
  8. _setup.push.apply(args, arguments);
  9. return _chainResult(this, func.apply(underscore, args));
  10. };
  11. });
  12. return underscore;
  13. }
  14. return mixin;
  15. });