MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / printBasicValue

Method printBasicValue

packages/alphatab/test/PrettyFormat.ts:124–147  ·  view source on GitHub ↗

* The first port of call for printing an object, handles most of the * data-types in JS.

(val: unknown, escapeString: boolean)

Source from the content-addressed store, hash-verified

122 * data-types in JS.
123 */
124 static printBasicValue(val: unknown, escapeString: boolean): string | null {
125 switch (typeof val) {
126 case 'string':
127 if (escapeString) {
128 return `"${(val as string).replaceAll(/"|\\/g, v => `\\${v}`)}"`;
129 }
130 return `"${val}"`;
131 case 'number':
132 return PrettyFormat.printNumber(val as number);
133 case 'bigint':
134 return PrettyFormat.printBigInt(val as bigint);
135 case 'boolean':
136 return `${val}`;
137 case 'undefined':
138 return 'undefined';
139 case 'object':
140 if (val === null) {
141 return 'null';
142 }
143 break;
144 }
145
146 return null;
147 }
148
149 static tryGetIterableType(val: unknown): string {
150 if (val instanceof Float32Array) {

Callers 1

printerMethod · 0.80

Calls 2

printNumberMethod · 0.80
printBigIntMethod · 0.80

Tested by

no test coverage detected