protective
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

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"

Package Sidebar

Install

npm i protective

Weekly Downloads

0

Version

0.0.0

License

Unlicense

Unpacked Size

4.64 kB

Total Files

9

Last publish

Collaborators

  • omrilotan