(factory: () => unknown)
| 13 | * @param factory - A function that returns the value of this property. |
| 14 | */ |
| 15 | export function lazy(factory: () => unknown): PropertyDecorator { |
| 16 | return (target, propertyKey) => { |
| 17 | let value: unknown = UNINITIALIZED; |
| 18 | Object.defineProperty(target, propertyKey, { |
| 19 | get(): any { |
| 20 | if (value === UNINITIALIZED) { |
| 21 | value = factory.call(this); |
| 22 | } |
| 23 | return value; |
| 24 | }, |
| 25 | }); |
| 26 | }; |
| 27 | } |
no outgoing calls
no test coverage detected