UNPKG

stencil-quantum

Version:

Experience the quantum realm of stencil.

22 lines (21 loc) 551 B
//#region Logging const _log = (...args) => _log.debug && console.log(...args); _log.debug = false; export const log = _log; export const nop = () => { }; ; export function hookComponent(prototype, key, cb) { const _original = prototype[key] || nop; prototype[key] = async function (...args) { log(key, this); const cb2 = await cb(this); let result = await _original.apply(this, args); if (cb2 instanceof Function) await cb2(this); return result; }; return () => { prototype[key] = _original; }; } //#endregion