| 310 | const compositeRules = [classRule, symbolRule, customRule, typedArrayRule]; |
| 311 | |
| 312 | export 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 | |
| 340 | const simpleRulesByAnnotation: Record<string, typeof simpleRules[0]> = {}; |
| 341 | simpleRules.forEach(rule => { |