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

1234567891011121314151617181920212223242526272829
  1. var copyArray = require('./_copyArray'),
  2. isIndex = require('./_isIndex');
  3. /* Built-in method references for those with the same name as other `lodash` methods. */
  4. var nativeMin = Math.min;
  5. /**
  6. * Reorder `array` according to the specified indexes where the element at
  7. * the first index is assigned as the first element, the element at
  8. * the second index is assigned as the second element, and so on.
  9. *
  10. * @private
  11. * @param {Array} array The array to reorder.
  12. * @param {Array} indexes The arranged array indexes.
  13. * @returns {Array} Returns `array`.
  14. */
  15. function reorder(array, indexes) {
  16. var arrLength = array.length,
  17. length = nativeMin(indexes.length, arrLength),
  18. oldArray = copyArray(array);
  19. while (length--) {
  20. var index = indexes[length];
  21. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22. }
  23. return array;
  24. }
  25. module.exports = reorder;