Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
419 B
JavaScript
Raw Permalink Normal View History

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 };