UNPKG

@extra-array/copy-within.min

Version:
63 lines (46 loc) 1.99 kB
Copies part of array within. [:package:](https://www.npmjs.com/package/@extra-array/copy-within) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/copy-within) [:vhs:](https://asciinema.org/a/332032) [:moon:](https://www.npmjs.com/package/@extra-array/copy-within.min) [:scroll:](https://unpkg.com/@extra-array/copy-within/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [copyWithin], [copyWithin$].<br> > Similar: [copy], [copyWithin], [moveWithin]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array > This is browserified, minified version of [@extra-array/copy-within].<br> > It is exported as global variable **array_copyWithin**.<br> > CDN: [unpkg], [jsDelivr]. [@extra-array/copy-within]: https://www.npmjs.com/package/@extra-array/copy-within [unpkg]: https://unpkg.com/@extra-array/copy-within.min [jsDelivr]: https://cdn.jsdelivr.net/npm/@extra-array/copy-within.min <br> ```javascript array.copyWithin(x, [j], [i], [I]); // x: an array // j: write index (0) // i: read start index (0) // I: read end index (X) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, 5]; array.copyWithin(x, 3); // [ 1, 2, 3, 1, 2 ] array.copyWithin(x, 3, 1); // [ 1, 2, 3, 2, 3 ] array.copyWithin(x, 3, 1, 2); // [ 1, 2, 3, 2, 5 ] ``` <br> <br> ## References - [Array.prototype.copyWithin: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) - [immutable-iterable-prototype: @azu](https://github.com/azu/immutable-iterable-prototype) [copyWithin]: https://github.com/nodef/extra-array/wiki/copyWithin [copyWithin$]: https://github.com/nodef/extra-array/wiki/copyWithin$ [copy]: https://github.com/nodef/extra-array/wiki/copy [moveWithin]: https://github.com/nodef/extra-array/wiki/moveWithin