array-moveto

Move part of array to another array.

Usage no npm install needed!

<script type="module">
  import arrayMoveto from 'https://cdn.skypack.dev/array-moveto';
</script>

README

array-moveto

NOTE: array-moveto was renamed to @extra-array/move. NPM

Move part of array to another array.

const moveTo = require('array-moveto');
// moveTo(<array>, [clear=0], [begin=0], [end], [target=[]], [at], [till])
// -> <target>

moveTo(['p', 'o', 'r', 't']);
// ['p', 'o', 'r', 't'] (array: [0, 0, 0, 0])
moveTo(['p', 'o', 'r', 't'], null);
// ['p', 'o', 'r', 't'] (array: [null, null, null, null])
moveTo(['p', 'o', 'r', 't'], null, 1);
// ['o', 'r', 't']      (array: ['p', null, null, null])
moveTo(['p', 'o', 'r', 't'], null, 1, 3);
// ['o', 'r']           (array: ['p', null, null, 't'])
moveTo(['p', 'o', 'r', 't'], null, 1, 3, ['d', 'o']);
// ['d', 'o', 'o', 'r'] (array: ['p', null, null, 't'])
moveTo(['p', 'o', 'r', 't'], null, 1, 3, ['d', 'o'], 1);
// ['d', 'o', 'r']      (array: ['p', null, null, 't'])