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

Function shallowObj

packages/zone.js/lib/zone-spec/wtf.ts:164–184  ·  view source on GitHub ↗
(obj: {[k: string]: any} | undefined, depth: number)

Source from the content-addressed store, hash-verified

162 }
163
164 function shallowObj(obj: {[k: string]: any} | undefined, depth: number): any {
165 if (!obj || !depth) return null;
166 const out: {[k: string]: any} = {};
167 for (const key in obj) {
168 if (obj.hasOwnProperty(key)) {
169 // explicit : any due to https://github.com/microsoft/TypeScript/issues/33191
170 let value: any = obj[key];
171 switch (typeof value) {
172 case 'object':
173 const name = value && value.constructor && (<any>value.constructor).name;
174 value = name == (<any>Object).name ? shallowObj(value, depth - 1) : name;
175 break;
176 case 'function':
177 value = value.name || undefined;
178 break;
179 }
180 out[key] = value;
181 }
182 }
183 return out;
184 }
185
186 function zonePathName(zone: Zone) {
187 let name: string = zone.name;

Callers 2

onScheduleTaskMethod · 0.85
onCancelTaskMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected