We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b2b5d7 commit 738cbe8Copy full SHA for 738cbe8
solution/2600-2699/2666.Allow One Function Call/Solution.ts
@@ -1,6 +1,7 @@
1
-function once<T extends (...args: any[]) => any>(
2
- fn: T,
3
-): (...args: Parameters<T>) => ReturnType<T> | undefined {
+type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
+type OnceFn = (...args: JSONValue[]) => JSONValue | undefined;
+
4
+function once(fn: Function): OnceFn {
5
let called = false;
6
return function (...args) {
7
if (!called) {
0 commit comments