json-logic-engine
Version:
Construct complex rules with JSON & process them.
19 lines (18 loc) • 526 B
JavaScript
// @ts-check
/**
* Checks if optional chaining is supported for the compiler
* @returns {Boolean}
*/
const getIsOptionalChainingSupported = () => {
try {
// eslint-disable-next-line no-unused-vars
const test = {}
// eslint-disable-next-line no-eval
const isUndefined = (typeof globalThis !== 'undefined' ? globalThis : global).eval('(test) => test?.foo?.bar')(test)
return isUndefined === undefined
} catch (err) {
return false
}
}
export default getIsOptionalChainingSupported()