Spaces:
Paused
Paused
Download node_modules/@plotly/mapbox-gl/src/util/throttle.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 573 Bytes
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/throttle.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@plotly/mapbox-gl/src/util/throttle.js
-
curl -L -o throttle.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/util/throttle.js
573 Bytes
| // @flow strict | |
| /** | |
| * Throttle the given function to run at most every `period` milliseconds. | |
| * @private | |
| */ | |
| export default function throttle(fn: () => void, time: number): () => ?TimeoutID { | |
| let pending = false; | |
| let timerId: ?TimeoutID = null; | |
| const later = () => { | |
| timerId = null; | |
| if (pending) { | |
| fn(); | |
| timerId = setTimeout(later, time); | |
| pending = false; | |
| } | |
| }; | |
| return () => { | |
| pending = true; | |
| if (!timerId) { | |
| later(); | |
| } | |
| return timerId; | |
| }; | |
| } | |