0.0.2 • Published 8 years ago

catch-json-parse v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

catch-json-parse

#####JSON.parse in a try-catch with error handler

####Why?

I wanted to:

  • get rid of the try catch block in my code
  • be able to still use the catch as an error handler

--

parseJson= require( 'catch-json-parse' );

var json= JSON.stringify();

var errHandler= function( err ){
	console.log( err );
	//	[SyntaxError: Unexpected token u]
};

var obj= parseJSON( json, errHandler ) || {};

console.log( obj );
//	{}

###license

MIT

0.0.2

8 years ago

0.0.1

8 years ago