File size: 706 Bytes
68465df | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /**
* Expo Router stores route params as strings, so a legacy advertisement's
* `false` arrives as `"false"`. Missing means the scan did not say.
*/
export const parseOptionalBoolean = (value: unknown): boolean | undefined => {
if (typeof value === "boolean") return value
if (value === "true") return true
if (value === "false") return false
return undefined
}
/**
* Prefer the device payload. JSON keeps the original boolean when the separate
* route flag is dropped or stringified.
*/
export const advertisedSecurePairingCapable = (routeValue: unknown, deviceValue: unknown): boolean | undefined =>
parseOptionalBoolean(deviceValue) ?? parseOptionalBoolean(routeValue)
|