MCPcopy
hub / github.com/angular/angular / iterateListLike

Function iterateListLike

packages/core/src/util/iterable.ts:39–51  ·  view source on GitHub ↗
(obj: Iterable<T>, fn: (p: T) => void)

Source from the content-addressed store, hash-verified

37}
38
39export function iterateListLike<T>(obj: Iterable<T>, fn: (p: T) => void) {
40 if (Array.isArray(obj)) {
41 for (let i = 0; i < obj.length; i++) {
42 fn(obj[i]);
43 }
44 } else {
45 const iterator = obj[Symbol.iterator]();
46 let item: IteratorResult<T, any>;
47 while (!(item = iterator.next()).done) {
48 fn(item.value);
49 }
50 }
51}
52
53export function isJsObject(o: any): boolean {
54 return o !== null && (typeof o === 'function' || typeof o === 'object');

Callers 2

query_list_spec.tsFile · 0.90
checkMethod · 0.90

Calls 3

isArrayMethod · 0.80
fnFunction · 0.50
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…