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

each.js 746B

12345678910111213141516171819202122232425
  1. define(['./keys', './_optimizeCb', './_isArrayLike'], function (keys, _optimizeCb, _isArrayLike) {
  2. // The cornerstone for collection functions, an `each`
  3. // implementation, aka `forEach`.
  4. // Handles raw objects in addition to array-likes. Treats all
  5. // sparse array-likes as if they were dense.
  6. function each(obj, iteratee, context) {
  7. iteratee = _optimizeCb(iteratee, context);
  8. var i, length;
  9. if (_isArrayLike(obj)) {
  10. for (i = 0, length = obj.length; i < length; i++) {
  11. iteratee(obj[i], i, obj);
  12. }
  13. } else {
  14. var _keys = keys(obj);
  15. for (i = 0, length = _keys.length; i < length; i++) {
  16. iteratee(obj[_keys[i]], _keys[i], obj);
  17. }
  18. }
  19. return obj;
  20. }
  21. return each;
  22. });