MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / decodeValue

Function decodeValue

packages/nativescript-inspector/src/index.ts:2477–2509  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

2475}
2476
2477function decodeValue(value: unknown): unknown {
2478 if (!value || typeof value !== "object") {
2479 return value;
2480 }
2481 const object = value as JSONObject;
2482 switch (object.$type) {
2483 case "UIColor":
2484 return colorFromObject(object);
2485 case "CGRect":
2486 return CGRectMake(
2487 numberValue(object.x),
2488 numberValue(object.y),
2489 numberValue(object.width),
2490 numberValue(object.height),
2491 );
2492 case "CGPoint":
2493 return CGPointMake(numberValue(object.x), numberValue(object.y));
2494 case "CGSize":
2495 return CGSizeMake(numberValue(object.width), numberValue(object.height));
2496 case "UIEdgeInsets":
2497 return UIEdgeInsetsMake(
2498 numberValue(object.top),
2499 numberValue(object.left),
2500 numberValue(object.bottom),
2501 numberValue(object.right),
2502 );
2503 default:
2504 if ("hex" in object) {
2505 return colorFromObject(object);
2506 }
2507 return value;
2508 }
2509}
2510
2511function colorFromObject(object: JSONObject): any {
2512 if (typeof object.hex === "string") {

Callers 1

setPropertyMethod · 0.85

Calls 2

colorFromObjectFunction · 0.85
numberValueFunction · 0.85

Tested by

no test coverage detected