(target: any, initializer: Initializer<T>)
| 3 | export type Initializer<T> = (instance: T, context?: any) => void; |
| 4 | |
| 5 | export function addInitializer<T>(target: any, initializer: Initializer<T>) { |
| 6 | if (!target[INITIALIZERS]) { |
| 7 | target[INITIALIZERS] = []; |
| 8 | } else if ( |
| 9 | // if one of the prototypes has initializers |
| 10 | target[INITIALIZERS] && |
| 11 | // and it's not the target object itself |
| 12 | !Object.prototype.hasOwnProperty.call(target, INITIALIZERS) |
| 13 | ) { |
| 14 | const base = Object.getPrototypeOf(target); |
| 15 | target[INITIALIZERS] = [...base[INITIALIZERS]]; |
| 16 | } |
| 17 | |
| 18 | target[INITIALIZERS].push(initializer); |
| 19 | } |
| 20 | |
| 21 | export function initialize(target: any, context?: any) { |
| 22 | if (target[INITIALIZERS]) { |
no outgoing calls
no test coverage detected