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

Function iterateListLike

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

Source from the content-addressed store, hash-verified

33}
34
35export function iterateListLike<T>(obj: Iterable<T>, fn: (p: T) => void) {
36 if (Array.isArray(obj)) {
37 for (let i = 0; i < obj.length; i++) {
38 fn(obj[i]);
39 }
40 } else {
41 const iterator = obj[Symbol.iterator]();
42 let item: IteratorResult<T, any>;
43 while (!(item = iterator.next()).done) {
44 fn(item.value);
45 }
46 }
47}
48
49export function isJsObject(o: any): boolean {
50 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