( function_: (...arguments_: ArgumentsType) => ReturnType, )
| 1 | const notRun = Symbol('false'); |
| 2 | export default function onetime<ArgumentsType extends unknown[], ReturnType>( |
| 3 | function_: (...arguments_: ArgumentsType) => ReturnType, |
| 4 | ): (...arguments_: ArgumentsType) => ReturnType { |
| 5 | let returnValue: ReturnType | typeof notRun = notRun; |
| 6 | return function(this: unknown, ...arguments_: ArgumentsType): ReturnType { |
| 7 | if (returnValue !== notRun) { |
| 8 | return returnValue; |
| 9 | } |
| 10 | |
| 11 | returnValue = Reflect.apply(function_, this, arguments_); |
| 12 | return returnValue; |
| 13 | }; |
| 14 | } |
no outgoing calls
no test coverage detected