0.0.0 • Published 2 years ago
protective v0.0.0
protective
🥽 Runtime protective gear
stringify
Resort to simple string conversion when JSON.stringify fails
import { stringify } from 'protective';
const something = { key: 'Balue' };
something.circular = something;
JSON.stringify(something, null, 2); // TypeError: Converting circular structure to JSON
stringify(something, null, 2); // '[object Object]'
verbose
Add arguments to function error messages
import { verbose } from 'protective';
function myFunction() {
throw new Error('This is an error');
}
myFunction('one', 'two'); // Error: This is an error
verbose(myFunction)('one', 'two'); // Error: This is an error. Arguments: "one", "two"
0.0.0
2 years ago