UNPKG

helene

Version:
39 lines 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.adjustTypesFromJSONValue = void 0; /** * for both arrays and objects. Tries its best to just * use the object you hand it, but may return something * different if the object you hand it itself needs changing. */ const utils_1 = require("./utils"); const from_json_value_helper_1 = require("./helpers/from-json-value-helper"); const adjustTypesFromJSONValue = obj => { if (obj === null) { return null; } const maybeChanged = (0, from_json_value_helper_1.fromJSONValueHelper)(obj); if (maybeChanged !== obj) { return maybeChanged; } // Other atoms are unchanged. if (!(0, utils_1.isObject)(obj)) { return obj; } (0, utils_1.keysOf)(obj).forEach(key => { const value = obj[key]; if ((0, utils_1.isObject)(value)) { const changed = (0, from_json_value_helper_1.fromJSONValueHelper)(value); if (value !== changed) { obj[key] = changed; return; } // if we get here, value is an object but not adjustable // at this level. recurse. (0, exports.adjustTypesFromJSONValue)(value); } }); return obj; }; exports.adjustTypesFromJSONValue = adjustTypesFromJSONValue; //# sourceMappingURL=adjust-types-from-json-value.js.map