Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
90
Evaluation — 90%
↑ 1.08xAgent success when using this tile
Build a utility that generates human-readable preview strings for large objects and arrays. When working with objects that have many properties or arrays with many elements, it can be useful to display a truncated version that shows only the first few items for readability.
Create a function that serializes objects but limits the number of properties shown. This helps when logging or displaying large objects where showing all properties would be overwhelming.
Create a function that serializes arrays but limits the number of elements shown. This is particularly useful for logging large data sets where you only need to see a sample.
The preview generation should work correctly with nested objects and arrays, applying the breadth limit at each level of the structure.
@generates
/**
* Creates a preview generator with a specified property/element limit.
*
* @param {number} maxItems - Maximum number of properties/elements to include per object/array
* @returns {function} A function that generates preview strings
*/
function createPreviewGenerator(maxItems) {
// Returns a function with signature: (value) => string
}
module.exports = { createPreviewGenerator };Provides JSON serialization with configurable breadth limiting to control how many properties or elements are included in the output.
@satisfied-by
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