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

map.js 561B

12345678910111213141516
  1. import cb from './_cb.js';
  2. import isArrayLike from './_isArrayLike.js';
  3. import keys from './keys.js';
  4. // Return the results of applying the iteratee to each element.
  5. export default function map(obj, iteratee, context) {
  6. iteratee = cb(iteratee, context);
  7. var _keys = !isArrayLike(obj) && keys(obj),
  8. length = (_keys || obj).length,
  9. results = Array(length);
  10. for (var index = 0; index < length; index++) {
  11. var currentKey = _keys ? _keys[index] : index;
  12. results[index] = iteratee(obj[currentKey], currentKey, obj);
  13. }
  14. return results;
  15. }