UNPKG

surrogate

Version:

Object method hooks made easy

73 lines (62 loc) 2.75 kB
var $8f5bd6cc0f9bb93b$exports = require("./surrogate.1545c2f2.js"); var $173529f42333421b$exports = require("./surrogate.014ad084.js"); var $5da807cc202126ea$exports = require("./surrogate.68dbcc9f.js"); var $69e6bb98e7bc51ac$exports = require("./surrogate.5de640eb.js"); var $iuaT7$jfrazxasarray = require("@jfrazx/asarray"); function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "manageDecorator", () => $3e0684a3e4432a28$export$50613b79e775cc76); $parcel$export(module.exports, "determineWhich", () => $3e0684a3e4432a28$export$8eec127a839d06d3); $parcel$export(module.exports, "manageAsyncDecorator", () => $3e0684a3e4432a28$export$96e2c81bb82b5871); const $3e0684a3e4432a28$export$50613b79e775cc76 = (type, options)=>{ const decoratorOptions = $3e0684a3e4432a28$var$organizeOptions(options); return (target, event)=>{ (0, $8f5bd6cc0f9bb93b$exports.SurrogateClassWrapper).addDecorators(target.constructor, type, event, decoratorOptions); }; }; const $3e0684a3e4432a28$export$8eec127a839d06d3 = (type)=>type === (0, $173529f42333421b$exports.BOTH) ? [ (0, $173529f42333421b$exports.PRE), (0, $173529f42333421b$exports.POST) ] : [ type ]; const $3e0684a3e4432a28$export$96e2c81bb82b5871 = (type, options)=>{ const wrapper = { wrapper: (0, $5da807cc202126ea$exports.MethodWrapper).Async }; const asyncOptions = (0, $iuaT7$jfrazxasarray.asArray)(options).map((opt)=>$3e0684a3e4432a28$var$isDecoratorOptions(opt) ? { ...opt, options: { ...opt.options, ...wrapper } } : { handler: opt, options: { ...wrapper } }); return $3e0684a3e4432a28$export$50613b79e775cc76(type, asyncOptions); }; const $3e0684a3e4432a28$var$organizeOptions = (delegateOptions)=>{ return (0, $iuaT7$jfrazxasarray.asArray)(delegateOptions).flatMap((value)=>{ return $3e0684a3e4432a28$var$isDecoratorOptions(value) ? $3e0684a3e4432a28$var$mapHandlers(value) : [ { handler: value, options: {} } ]; }); }; const $3e0684a3e4432a28$var$mapHandlers = (decoratorOptions)=>{ const { handler: handlers, options: options = {} } = decoratorOptions; return (0, $iuaT7$jfrazxasarray.asArray)(handlers).map((handler)=>({ handler: handler, options: { ...options } })); }; const $3e0684a3e4432a28$var$isDecoratorOptions = (value)=>(0, $69e6bb98e7bc51ac$exports.isObject)(value); //# sourceMappingURL=surrogate.de4acfe1.js.map