UNPKG

providence-analytics

Version:

Providence is the 'All Seeing Eye' that measures effectivity and popularity of software. Release management will become highly efficient due to an accurate impact analysis of (breaking) changes

41 lines (37 loc) 1.09 kB
import { GlobalDecorator } from './GlobalDecorator.js'; // TODO: dedupe via @lion export const DecorateMixin = superclass => { // eslint-disable-next-line no-shadow class DecorateMixin extends superclass { /** * * @param {CssResult[]} styles * @param {boolean} prepend */ static decorateStyles(styles, { prepend } = {}) { if (!prepend) { this.__decoratedStyles.push(styles); } else { this.__decoratedStylesPrepended.push(styles); } } static decorateMethod(name, fn) { const originalMethod = this.prototype[name]; this.prototype[name] = (...args) => { fn(originalMethod, ...args); }; } static get styles() { return [ ...GlobalDecorator.globalDecoratedStylesPrepended, ...this.__decoratedStylesPrepended, ...(super.styles || []), ...GlobalDecorator.globalDecoratedStyles, ...this.__decoratedStyles, ]; } } DecorateMixin.__decoratedStyles = []; DecorateMixin.__decoratedStylesPrepended = []; return DecorateMixin; };