docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a configuration file sanitizer that processes application settings by removing unset values while preserving explicitly null values. The sanitizer should convert between JavaScript objects and XML format while maintaining the semantic distinction between missing values and intentionally null values.
Your implementation should:
{name: "app", version: undefined} produces XML without a version property @test{name: "app", version: null} produces XML with an explicit null element for version @test{host: "localhost", port: undefined, timeout: null} correctly omits port and preserves timeout as null @test/**
* Sanitizes a configuration object by converting it to XML format.
* Undefined values are omitted, null values are explicitly marked.
*
* @param {Object} config - Configuration object to sanitize
* @returns {string} XML representation of the configuration
*/
function sanitize(config) {
// IMPLEMENTATION HERE
}
/**
* Restores a configuration object from its XML representation.
* Null markers are converted to null, missing values become empty strings.
*
* @param {string} xml - XML string to parse
* @returns {Object} Configuration object
*/
function restore(xml) {
// IMPLEMENTATION HERE
}
module.exports = {
sanitize,
restore
};Provides XML property list parsing and building with proper null/undefined semantics.