artdaq_node_server  v1_00_08
 All Classes Namespaces Files Variables Pages
_reorder.js
1 var copyArray = require('./_copyArray'),
2  isIndex = require('./_isIndex');
3 
4 /* Built-in method references for those with the same name as other `lodash` methods. */
5 var nativeMin = Math.min;
6 
17 function reorder(array, indexes) {
18  var arrLength = array.length,
19  length = nativeMin(indexes.length, arrLength),
20  oldArray = copyArray(array);
21 
22  while (length--) {
23  var index = indexes[length];
24  array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
25  }
26  return array;
27 }
28 
29 module.exports = reorder;