Files
test-repo/scripts/build/shims/shared.js
T
fisker Cheungandautofix-ci[bot] 011791fd6c Improve method transform (#18135)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-28 02:51:50 +08:00

16 lines
419 B
JavaScript

const OPTIONAL_OBJECT = 0x01;
const createMethodShim =
(methodName, getImplementation) =>
(flags, object, ...arguments_) => {
if (flags | OPTIONAL_OBJECT && (object === undefined || object === null)) {
return;
}
const implementation = getImplementation.call(object) ?? object[methodName];
return implementation.apply(object, arguments_);
};
export { createMethodShim, OPTIONAL_OBJECT };