MCPcopy
hub / github.com/immutable-js/immutable-js / shallowCopy

Function shallowCopy

src/utils/shallowCopy.ts:7–24  ·  view source on GitHub ↗
(
  from: Array<I> | O
)

Source from the content-addressed store, hash-verified

5export default function shallowCopy<I>(from: Array<I>): Array<I>;
6export default function shallowCopy<O extends object>(from: O): O;
7export default function shallowCopy<I, O extends object>(
8 from: Array<I> | O
9): Array<I> | O {
10 if (Array.isArray(from)) {
11 return arrCopy(from);
12 }
13 const to: Partial<O> = {};
14 for (const key in from) {
15 if (isProtoKey(key)) {
16 continue;
17 }
18
19 if (hasOwnProperty.call(from, key)) {
20 to[key] = from[key];
21 }
22 }
23 return to as O;
24}

Callers 4

removeFunction · 0.85
setFunction · 0.85
mergeWithSourcesFunction · 0.85
shallowCopy.tsFile · 0.85

Calls 2

isProtoKeyFunction · 0.90
arrCopyFunction · 0.85

Tested by

no test coverage detected