Spaces:
Paused
Paused
Download node_modules/@plotly/mapbox-gl/src/util/throttled_invoker.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/throttled_invoker.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@plotly/mapbox-gl/src/util/throttled_invoker.js
-
curl -L -o throttled_invoker.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/throttled_invoker.js
1.15 kB
| // @flow | |
| /** | |
| * Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests | |
| * are ignored until the function was actually invoked. | |
| * | |
| * @private | |
| */ | |
| class ThrottledInvoker { | |
| _channel: MessageChannel; | |
| _triggered: boolean; | |
| _callback: Function | |
| constructor(callback: Function) { | |
| this._callback = callback; | |
| this._triggered = false; | |
| if (typeof MessageChannel !== 'undefined') { | |
| this._channel = new MessageChannel(); | |
| this._channel.port2.onmessage = () => { | |
| this._triggered = false; | |
| this._callback(); | |
| }; | |
| } | |
| } | |
| trigger() { | |
| if (!this._triggered) { | |
| this._triggered = true; | |
| if (this._channel) { | |
| this._channel.port1.postMessage(true); | |
| } else { | |
| setTimeout(() => { | |
| this._triggered = false; | |
| this._callback(); | |
| }, 0); | |
| } | |
| } | |
| } | |
| remove() { | |
| delete this._channel; | |
| this._callback = () => {}; | |
| } | |
| } | |
| export default ThrottledInvoker; | |