surrogate
Version:
Object method hooks made easy
40 lines (31 loc) • 1.45 kB
JavaScript
var $fac0fcc12ea00358$exports = require("./surrogate.23b4664a.js");
var $2f755d1f1cdaf310$exports = require("./surrogate.49912d43.js");
var $69e6bb98e7bc51ac$exports = require("./surrogate.5de640eb.js");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "BaseContainer", () => $764b793760293d3e$export$89c285f228afdc27);
class $764b793760293d3e$export$89c285f228afdc27 {
constructor(handler, type, options = new (0, $2f755d1f1cdaf310$exports.OptionsHandler)()){
this.handler = handler;
this.type = type;
this.options = options;
}
getHandler(context) {
const { target: target, receiver: receiver } = context;
return this.shouldReflect(this.handler) ? this.shouldReflectSurrogate(context) ? /**
* @note Removes ability to apply target only
* @todo fix ^^
*/ Reflect.get(receiver, this.handler, receiver) : Reflect.get(target, this.handler, receiver) : this.handler;
}
shouldReflect(value) {
return !(0, $69e6bb98e7bc51ac$exports.isFunction)(value);
}
shouldReflectSurrogate(context) {
return context.useSurrogate(this.options.useContext);
}
getHandlerRunner(node) {
return (0, $fac0fcc12ea00358$exports.HandlerRunner).for(node, this.options);
}
}
//# sourceMappingURL=surrogate.e9dcee1f.js.map