MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / typeOf

Function typeOf

Extension/src/Utility/System/info.ts:10–33  ·  view source on GitHub ↗
(instance: any)

Source from the content-addressed store, hash-verified

8import { AribtraryObject, Constructor } from './types';
9
10export function typeOf(instance: any) {
11 const t = typeof instance;
12 const c = (classOf(instance) as any);
13 switch (t) {
14 case 'number':
15 return Number.isNaN(instance) ? 'NaN' : 'number';
16
17 case 'object':
18 if (instance === null) {
19 return 'null';
20 }
21 if (is.promise(instance)) {
22 return c.class ? `Promise<${classOf(c.class)?.name || parentClassOf(classOf(c.class)!)?.name}>` : 'Promise';
23 }
24 return classOf(instance)?.name || parentClassOf(classOf(instance)!)?.name || '<anonymous>';
25 case 'function':
26 if (is.Constructor(instance)) {
27 return `class ${c?.name || parentClassOf(c!)?.name || '<anonymous>'}`;
28 }
29 return 'function';
30
31 }
32 return t;
33}
34
35export function hierarchy(instance: AribtraryObject | Constructor): string[] {
36 const result = new Array<string>();

Callers 3

typeinfo.test.tsFile · 0.90
removeAllListenersFunction · 0.90
onFunction · 0.90

Calls 4

classOfFunction · 0.85
parentClassOfFunction · 0.85
promiseMethod · 0.80
ConstructorMethod · 0.80

Tested by

no test coverage detected