array-copyto
v0.1.7
Published
Copy part of array to another array, like Array.slice().
Downloads
170
Readme
array-copyto
NOTE: array-copyto was renamed to @extra-array/copy.
Copy part of array to another array, like Array.slice().
Uses Array.length and Array.copyWithin() to improve performance. Ref: Array copy loop vs copy within.
const copyTo = require('array-copyto');
// copyTo(<array>, [begin=0], [end], [target=[]], [at], [till])
// -> <target>
copyTo(['p', 'o', 'r', 't']);
// ['p', 'o', 'r', 't']
copyTo(['p', 'o', 'r', 't'], 1);
// ['o', 'r', 't']
copyTo(['p', 'o', 'r', 't'], 1, 3);
// ['o', 'r']
copyTo(['p', 'o', 'r', 't'], 1, 3, ['d', 'o']);
// ['d', 'o', 'o', 'r']
copyTo(['p', 'o', 'r', 't'], 1, 3, ['d', 'o'], 1);
// ['d', 'o', 'r']