or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Configuration File Converter

Build a configuration converter that reads Apple property list XML files containing numeric settings and converts them to JavaScript objects, then modifies specific numeric values and writes them back to property list format.

Requirements

Your implementation should:

  1. Parse property list XML containing floating-point numeric values
  2. Extract and manipulate these floating-point values in JavaScript
  3. Convert modified JavaScript objects back to property list XML format
  4. Preserve floating-point precision during round-trip conversions

Implementation

@generates

API

/**
 * Converts a plist XML string to a JavaScript object.
 *
 * @param {string} xmlString - The plist XML string to parse
 * @returns {Object} The parsed JavaScript object
 */
function parsePlistConfig(xmlString) {
  // IMPLEMENTATION HERE
}

/**
 * Updates numeric settings in a configuration object.
 * Multiplies all numeric values by a scale factor.
 *
 * @param {Object} config - The configuration object
 * @param {number} scaleFactor - The scale factor to apply
 * @returns {Object} A new object with scaled numeric values
 */
function scaleNumericSettings(config, scaleFactor) {
  // IMPLEMENTATION HERE
}

/**
 * Converts a JavaScript object back to plist XML format.
 *
 * @param {Object} obj - The JavaScript object to convert
 * @returns {string} The plist XML string
 */
function buildPlistConfig(obj) {
  // IMPLEMENTATION HERE
}

module.exports = {
  parsePlistConfig,
  scaleNumericSettings,
  buildPlistConfig
};

Test Cases

  • Given a plist XML with a single real number value of 3.14, parsePlistConfig returns an object with that numeric value as a JavaScript Number @test
  • Given a plist XML with multiple real numbers (2.5, -10.75, 0.333), parsePlistConfig correctly converts all of them to JavaScript Numbers @test
  • Given a plist XML containing Math.PI's full precision (3.141592653589793), parsePlistConfig preserves all decimal places @test
  • Given an object with numeric values {temperature: 72.5, humidity: 0.65}, buildPlistConfig generates valid plist XML with real number elements @test
  • A round-trip conversion (XML → parse → build → XML) preserves floating-point values accurately @test

Dependencies { .dependencies }

plist { .dependency }

Provides property list parsing and building support.

@satisfied-by