is-json-value
Version:
Check if a value is valid JSON
30 lines (24 loc) • 860 B
JavaScript
export const isWarning=({reason})=>!VALID_REASONS.has(reason);
const VALID_REASONS=new Set([
"descriptorNotConfigurable",
"descriptorNotWritable",
"unresolvedGetter",
"unresolvedToJSON"]
);
export const getDescription=(reason)=>`must ${DESCRIPTIONS[reason]}.`;
export const DESCRIPTIONS={
ignoredArrayProperty:"not be a property on an array",
ignoredFunction:"not be a function",
ignoredNotEnumerable:"be enumerable",
ignoredSymbolKey:"not have a symbol key",
ignoredSymbolValue:"not be a symbol",
ignoredUndefined:"not be undefined",
unresolvedClass:"be a plain object",
unsafeBigInt:"not be a bigint",
unsafeCycle:"not be a circular value",
unsafeException:"not throw an exception",
unsafeGetter:"not throw an exception",
unsafeSize:"have a smaller size",
unsafeToJSON:"not throw an exception in toJSON()",
unstableInfinite:"not be NaN nor Infinity"
};