Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
90
Evaluation — 90%
↑ 1.08xAgent success when using this tile
Build a data serialization service that handles high-volume logging scenarios efficiently. The service needs to process various types of data structures while maintaining high performance, especially when dealing with large datasets and different serialization requirements.
Basic Serializer
Optimized Large Object Handler
Specialized Serialization Configurations
src/serializer.jsserialize function that handles all casescreateSerializer function that creates optimized serializers for specific scenariosImplement test cases in src/serializer.test.js:
const data = { name: "Alice", age: 30, city: "NYC" };
const result = serialize(data);
// Should produce deterministic JSON string with sorted keysconst largeObject = {};
for (let i = 0; i < 500; i++) {
largeObject[`key${i}`] = `value${i}`;
}
const result = serialize(largeObject);
// Should efficiently serialize with sorted keys// Fast configuration - no transformations, no indentation
const fastSerializer = createSerializer({ mode: 'fast' });
const result1 = fastSerializer({ x: 1, y: 2 });
// Configuration with custom value transformation
const transformSerializer = createSerializer({
mode: 'transform',
transformer: (key, value) => typeof value === 'string' ? value.toUpperCase() : value
});
const result2 = transformSerializer({ name: "alice", age: 30 });
// Configuration with property whitelist
const selectiveSerializer = createSerializer({
mode: 'selective',
properties: ['name', 'age']
});
const result3 = selectiveSerializer({ name: "Bob", age: 25, city: "LA" });
// Should only include name and ageProvides safe and performant JSON serialization with deterministic output.
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