MCPcopy Index your code
hub / github.com/immutable-js/immutable-js / arrCopy

Function arrCopy

src/utils/arrCopy.ts:3–12  ·  view source on GitHub ↗
(arr: Array<I>, offset?: number)

Source from the content-addressed store, hash-verified

1// http://jsperf.com/copy-array-inline
2
3export default function arrCopy<I>(arr: Array<I>, offset?: number): Array<I> {
4 offset = offset || 0;
5 const len = Math.max(0, arr.length - offset);
6 const newArr: Array<I> = new Array(len);
7 for (let ii = 0; ii < len; ii++) {
8 // @ts-expect-error We may want to guard for undefined values with `if (arr[ii + offset] !== undefined`, but ths should not happen by design
9 newArr[ii] = arr[ii + offset];
10 }
11 return newArr;
12}

Callers 11

updateMethod · 0.85
updateMethod · 0.85
setAtFunction · 0.85
spliceFunction · 0.85
interleaveFunction · 0.85
zipFunction · 0.85
zipAllFunction · 0.85
zipWithFunction · 0.85
defaultZipperFunction · 0.85
shallowCopyFunction · 0.85
arrCopy.tsFile · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected