2025-11-18 20:40:21 +08:00
|
|
|
const OPTIONAL_OBJECT = 0b01;
|
2025-10-28 02:51:50 +08:00
|
|
|
|
|
|
|
|
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 };
|