Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
90
Evaluation — 90%
↑ 1.08xAgent success when using this tile
Build a utility that serializes deeply nested configuration objects for logging purposes, with the ability to control how deep the serialization goes to prevent overwhelming log output.
Your task is to implement a configuration logger that can handle complex, deeply nested configuration objects. The logger should be able to limit the depth of serialization to make log output more readable while still providing useful information about the structure.
Implement a function serializeConfig(config, options) that:
maxDepth property"[Object]" in the output"[Array]" in the outputconst config = {
server: {
port: 3000,
host: {
primary: "localhost",
fallback: {
local: "127.0.0.1",
remote: "0.0.0.0"
}
}
},
database: {
connections: [
{ name: "primary", pool: { min: 2, max: 10 } },
{ name: "replica", pool: { min: 1, max: 5 } }
]
}
};
serializeConfig(config, { maxDepth: 3 });
// Should limit nesting to 3 levels, showing "[Object]" and "[Array]" for deeper structures@generates
/**
* Serializes a configuration object to a JSON string with depth limiting.
*
* @param {Object} config - The configuration object to serialize
* @param {Object} options - Serialization options
* @param {number} options.maxDepth - Maximum depth of nesting to serialize
* @returns {string} JSON string representation with depth limiting applied
*/
function serializeConfig(config, options) {
// Implementation here
}
module.exports = { serializeConfig };Provides safe, deterministic JSON stringification with depth limiting support.
Install with Tessl CLI
npx tessl i tessl/npm-safe-stable-stringifydocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10