Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

bindAll.js 632B

12345678910111213141516171819
  1. define(['./_flatten', './restArguments', './bind'], function (_flatten, restArguments, bind) {
  2. // Bind a number of an object's methods to that object. Remaining arguments
  3. // are the method names to be bound. Useful for ensuring that all callbacks
  4. // defined on an object belong to it.
  5. var bindAll = restArguments(function(obj, keys) {
  6. keys = _flatten(keys, false, false);
  7. var index = keys.length;
  8. if (index < 1) throw new Error('bindAll must be passed function names');
  9. while (index--) {
  10. var key = keys[index];
  11. obj[key] = bind(obj[key], obj);
  12. }
  13. return obj;
  14. });
  15. return bindAll;
  16. });