MCPcopy
hub / github.com/GitbookIO/gitbook / formatExpressionResult

Function formatExpressionResult

packages/expr/src/utils.ts:4–18  ·  view source on GitHub ↗
(value: any, defaultValue = '')

Source from the content-addressed store, hash-verified

2 * Format the result value of an expression for display as a string.
3 */
4export function formatExpressionResult(value: any, defaultValue = ''): string {
5 if (value === undefined || value === null) {
6 return defaultValue;
7 }
8
9 if (typeof value === 'string') {
10 return value;
11 }
12
13 if (typeof value === 'number' || typeof value === 'boolean') {
14 return value.toString();
15 }
16
17 return defaultValue;
18}
19
20/**
21 * Filter function to exclude `null` values

Callers 2

evaluateTemplateMethod · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected