MCPcopy Create free account
hub / github.com/angular/angular / interleave

Function interleave

packages/compiler/src/expression_parser/serializer.ts:208–217  ·  view source on GitHub ↗

* Interleaves the two arrays, starting with the first item on the left, then the first item * on the right, second item from the left, and so on. When the first array's items are exhausted, * the remaining items from the other array are included with no interleaving.

(left: Left[], right: Right[])

Source from the content-addressed store, hash-verified

206 * the remaining items from the other array are included with no interleaving.
207 */
208function interleave<Left, Right>(left: Left[], right: Right[]): Array<Left | Right> {
209 const result: Array<Left | Right> = [];
210
211 for (let index = 0; index < Math.max(left.length, right.length); index++) {
212 if (index < left.length) result.push(left[index]);
213 if (index < right.length) result.push(right[index]);
214 }
215
216 return result;
217}

Callers 1

visitInterpolationMethod · 0.85

Calls 2

maxMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected