MCPcopy Index your code
hub / github.com/refined-github/refined-github / onetime

Function onetime

source/helpers/onetime.ts:2–14  ·  view source on GitHub ↗
(
	function_: (...arguments_: ArgumentsType) => ReturnType,
)

Source from the content-addressed store, hash-verified

1const notRun = Symbol('false');
2export 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}

Calls

no outgoing calls

Tested by

no test coverage detected