@wezom/toolkit-array
Version:
Useful tools for working with Arrays
22 lines (18 loc) • 489 B
JavaScript
;
var clone = require('./clone.js');
/**
* Clones an array and removes items by index
* @immutable
* @example
* arrayRemoveByIndex(['A', 'B', 'C'], 1) // >>> ['A', 'C'];
* arrayRemoveByIndex(['A', 'B', 'C', 'D', 'E'], 1, 3) // >>> ['A', 'E'];
*/
function removeByIndex(array, index, deleteCount) {
if (deleteCount === void 0) {
deleteCount = 1;
}
var clone$1 = clone(array);
clone$1.splice(index, deleteCount);
return clone$1;
}
module.exports = removeByIndex;