MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / transformCallback

Function transformCallback

ChatGPT/src-tauri/src/scripts/core.js:4–18  ·  view source on GitHub ↗
(callback = () => {}, once = false)

Source from the content-addressed store, hash-verified

2
3const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0];
4function transformCallback(callback = () => {}, once = false) {
5 const identifier = uid();
6 const prop = `_${identifier}`;
7 Object.defineProperty(window, prop, {
8 value: (result) => {
9 if (once) {
10 Reflect.deleteProperty(window, prop);
11 }
12 return callback(result)
13 },
14 writable: false,
15 configurable: true,
16 })
17 return identifier;
18}
19async function invoke(cmd, args) {
20 return new Promise((resolve, reject) => {
21 if (!window.__TAURI_POST_MESSAGE__) reject('__TAURI_POST_MESSAGE__ does not exist!');

Callers 1

invokeFunction · 0.85

Calls 1

uidFunction · 0.85

Tested by

no test coverage detected