MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / once

Function once

src/platform/common/utils/functional.ts:4–19  ·  view source on GitHub ↗
(this: unknown, fn: T)

Source from the content-addressed store, hash-verified

2// Licensed under the MIT License.
3
4export function once<T extends Function>(this: unknown, fn: T): T {
5 const _this = this;
6 let didCall = false;
7 let result: unknown;
8
9 return function () {
10 if (didCall) {
11 return result;
12 }
13
14 didCall = true;
15 result = fn.apply(_this, arguments);
16
17 return result;
18 } as unknown as T;
19}

Callers 9

createTrackerFunction · 0.90
createNotebookTrackerFunction · 0.90
startMethod · 0.90
writeToMementoCacheFunction · 0.90
toDisposableFunction · 0.90
acquireFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected