Skip to content

About

A commonly used array copy utility. (arrayCopy and arrayCopyTo)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

@tsdotnet/array-copy: Copy any array-like. A slice, or into a target.

npm version GitHub license

Copy all or part of an array-like into a new array, or into an existing target.

Install

npm install @tsdotnet/array-copy

Usage

import arrayCopy from '@tsdotnet/array-copy';

const a = [10, 20, 30, 40, 50];

arrayCopy(a);          // [10, 20, 30, 40, 50], a new array
arrayCopy(a, 1, 3);    // [20, 30, 40]: from index 1, up to 3 items
arrayCopy.to(a, [], 2); // [30, 40, 50]: into an existing target

Works on any array-like, such as arguments or typed arrays.

Use it from

ESM (import arrayCopy from '@tsdotnet/array-copy';) or CommonJS (const arrayCopy = require('@tsdotnet/array-copy').default;).

In a browser, without a bundler
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/array-init@1/dist/umd/array-init.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/exceptions@1/dist/umd/exceptions.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/array-copy@1/dist/umd/array-copy.min.js"></script>
<script>
  const arrayCopy = tsdotnet.arrayCopy.default;
</script>

Docs

tsdotnet.github.io/array-copy

About

A commonly used array copy utility. (arrayCopy and arrayCopyTo)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages