MCPcopy
hub / github.com/flightcontrolhq/superjson / transformValue

Function transformValue

src/transformer.ts:312–338  ·  view source on GitHub ↗
(
  value: any,
  superJson: SuperJSON
)

Source from the content-addressed store, hash-verified

310const compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
311
312export const transformValue = (
313 value: any,
314 superJson: SuperJSON
315): { value: any; type: TypeAnnotation } | undefined => {
316 const applicableCompositeRule = findArr(compositeRules, rule =>
317 rule.isApplicable(value, superJson)
318 );
319 if (applicableCompositeRule) {
320 return {
321 value: applicableCompositeRule.transform(value as never, superJson),
322 type: applicableCompositeRule.annotation(value, superJson),
323 };
324 }
325
326 const applicableSimpleRule = findArr(simpleRules, rule =>
327 rule.isApplicable(value, superJson)
328 );
329
330 if (applicableSimpleRule) {
331 return {
332 value: applicableSimpleRule.transform(value as never, superJson),
333 type: applicableSimpleRule.annotation,
334 };
335 }
336
337 return undefined;
338};
339
340const simpleRulesByAnnotation: Record<string, typeof simpleRules[0]> = {};
341simpleRules.forEach(rule => {

Callers 1

walkerFunction · 0.85

Calls 1

findArrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…