Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const parsed = JSON.parse(val);
if (!isDate(parsed) && isObject(parsed)) {
// throw new Error('Don\'t support object now');
return val;
} else if (
typeof parsed === 'number' &&
parsed.toLocaleString('fullwide', { useGrouping: false }) !== val
) {
// JS cannot handle big numbers. Leave it as a string to prevent data loss
return val;
}
return parsed;
} catch (ignored) {
if (isDateString(val)) {
return new Date(val);
}
return val;
}
}