MCPcopy Create free account
hub / github.com/angular/components / copyArrayItem

Function copyArrayItem

src/cdk/drag-drop/drag-utils.ts:63–74  ·  view source on GitHub ↗
(
  currentArray: T[],
  targetArray: T[],
  currentIndex: number,
  targetIndex: number,
)

Source from the content-addressed store, hash-verified

61 *
62 */
63export function copyArrayItem<T = any>(
64 currentArray: T[],
65 targetArray: T[],
66 currentIndex: number,
67 targetIndex: number,
68): void {
69 const to = clamp(targetIndex, targetArray.length);
70
71 if (currentArray.length) {
72 targetArray.splice(to, 0, currentArray[currentIndex]);
73 }
74}
75
76/** Clamps a number between zero and a maximum. */
77function clamp(value: number, max: number): number {

Callers 1

drag-utils.spec.tsFile · 0.90

Calls 1

clampFunction · 0.70

Tested by

no test coverage detected