tessl install tessl/npm-lodash-unescape@4.0.0Converts HTML entities to their corresponding characters in a string
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.39x
Baseline
Agent success rate without this tile
61%
Build a data parser utility that safely processes different data formats without throwing exceptions.
'{"name":"Alice","age":30}' returns the parsed object {name: "Alice", age: 30} @test'{bad json}' returns an error object @test'' returns an error object @test'42' returns the number 42 @test'abc' returns NaN @testtoUpperCase on string 'hello' returns 'HELLO' @testtoUpperCase on null value returns an error object @test@generates
/**
* Parses a JSON string safely, returning either the parsed value or an error.
*
* @param {string} jsonString - The JSON string to parse.
* @returns {Object|Error} The parsed object or an error object.
*/
function parseJSON(jsonString) {
// IMPLEMENTATION HERE
}
/**
* Parses an integer from a string safely, returning either the number or NaN.
*
* @param {string} str - The string to parse.
* @returns {number} The parsed integer or NaN.
*/
function parseInteger(str) {
// IMPLEMENTATION HERE
}
/**
* Executes a method on an object safely, returning either the result or an error.
*
* @param {*} obj - The object to execute the method on.
* @param {string} methodName - The name of the method to execute.
* @param {...*} args - Arguments to pass to the method.
* @returns {*|Error} The method result or an error object.
*/
function executeMethod(obj, methodName, ...args) {
// IMPLEMENTATION HERE
}
module.exports = {
parseJSON,
parseInteger,
executeMethod,
};Provides utility functions for safe function execution.
@satisfied-by