@livy/util
Version:
Common utilities for the Livy logger
26 lines (25 loc) • 904 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isFormattableHandlerInterface = void 0;
/**
* Check whether a value implements the FormattableHandlerInterface
*
* @param value The value to check
*/
function isFormattableHandlerInterface(value) {
if (typeof value !== 'object' || value === null) {
return false;
}
const descriptor = Object.getOwnPropertyDescriptor(value, 'formatter');
if (descriptor) {
return ((typeof descriptor.get === 'function' &&
typeof descriptor.set === 'function') ||
(Reflect.has(descriptor, 'value') &&
typeof descriptor.value === 'object' &&
descriptor.value !== null));
}
else {
return typeof value.formatter === 'object' && value.formatter !== null;
}
}
exports.isFormattableHandlerInterface = isFormattableHandlerInterface;