MCPcopy
hub / github.com/vue-leaflet/Vue2Leaflet / debounce

Function debounce

src/utils/utils.js:3–24  ·  view source on GitHub ↗
(fn, time)

Source from the content-addressed store, hash-verified

1import { setOptions } from 'leaflet';
2
3export const debounce = (fn, time) => {
4 let timeout;
5
6 const debouncedFunction = function(...args) {
7 const context = this;
8 if (timeout) {
9 clearTimeout(timeout);
10 }
11 timeout = setTimeout(() => {
12 fn.apply(context, args);
13 timeout = null;
14 }, time);
15 };
16
17 debouncedFunction.cancel = function() {
18 if (timeout) {
19 clearTimeout(timeout);
20 }
21 };
22
23 return debouncedFunction;
24};
25
26export const capitalizeFirstLetter = string => {
27 if (!string || typeof string.charAt !== 'function') {

Callers 1

debounce.spec.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected