fabiospampinato / is

The definitive collection of is* functions for runtime type checking. Lodash-compatible, tree-shakable, with types.
MIT License
16 stars 2 forks source link

New method: isValidJSON #3

Closed danielbayley closed 3 months ago

danielbayley commented 3 months ago

isValidJSON

Checks if a value is valid JSON.

import {isValidJSON} from 'is';

isValidJSON ( '{}' ); // => true
isValidJSON ( '{' ); // => false
fabiospampinato commented 3 months ago

Thanks, but this is a bit out of scope, in general almost every single function here has a type guard that narrows the type, this wouldn't narrow anything, and also all the parsing done for the string is thrown out of the window, which doesn't seem ideal for any scenario.