MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / interpolateProps

Method interpolateProps

src/lib/FancyError.ts:101–121  ·  view source on GitHub ↗

* Deep interpolate an object, replacing all string placeholders with context values.

(props: FancyErrorProps, context: ErrorContext)

Source from the content-addressed store, hash-verified

99 * Deep interpolate an object, replacing all string placeholders with context values.
100 */
101 private static interpolateProps (props: FancyErrorProps, context: ErrorContext): FancyErrorProps {
102 const result: FancyErrorProps = {};
103
104 for (const key of Object.keys(props)) {
105 const value = props[key];
106
107 if (typeof value === 'string') {
108 result[key] = FancyError.interpolate(value, context);
109 } else if (Array.isArray(value)) {
110 result[key] = value.map(item =>
111 typeof item === 'string' ? FancyError.interpolate(item, context) : item
112 );
113 } else if (typeof value === 'object' && value !== null && !(value instanceof NodeList)) {
114 result[key] = FancyError.interpolateProps(value as FancyErrorProps, context);
115 } else {
116 result[key] = value;
117 }
118 }
119
120 return result;
121 }
122
123 static pop (): void {
124 if (FancyError.isDevEnvironment() && typeof Prism !== 'undefined') {

Callers 1

showMethod · 0.80

Calls 2

interpolateMethod · 0.80
keysMethod · 0.65

Tested by

no test coverage detected