theta-client-react-native
Version:
This library provides a way to control RICOH THETA using.
41 lines (40 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertOptions = convertOptions;
exports.toNumber = toNumber;
exports.toStringValue = toStringValue;
function toNumber(value) {
if (typeof value === 'number' && Number.isFinite(value)) {
return value;
}
if (typeof value === 'string') {
const parsed = Number(value);
return Number.isFinite(parsed) ? parsed : undefined;
}
if (value != null && typeof value === 'object' && 'valueOf' in value) {
const primitive = value.valueOf();
return toNumber(primitive);
}
return undefined;
}
function toStringValue(value) {
return typeof value === 'string' && value.length > 0 ? value : undefined;
}
function convertOptions(options, jsonOptions) {
if (!jsonOptions) {
return options;
}
const result = {
...options
};
let jsonString = JSON.stringify(jsonOptions);
jsonString = jsonString.replace(/\\"/g, '"').replace(/\\n/g, '').replace(/"{/g, '{').replace(/}"/g, '}');
const parsedOptions = JSON.parse(jsonString);
if (parsedOptions.topBottomCorrectionRotationSupport) {
result.topBottomCorrectionRotationSupport = parsedOptions.topBottomCorrectionRotationSupport;
}
return result;
}
//# sourceMappingURL=convert-utils.js.map