MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / throttle

Function throttle

libs/leaflet/leaflet-src.js:81–107  ·  view source on GitHub ↗
(fn, time, context)

Source from the content-addressed store, hash-verified

79 // function, followed by any arguments passed when invoking the bound function.
80 // Has an `L.throttle` shortcut.
81 function throttle(fn, time, context) {
82 var lock, args, wrapperFn, later;
83
84 later = function () {
85 // reset lock and call if queued
86 lock = false;
87 if (args) {
88 wrapperFn.apply(context, args);
89 args = false;
90 }
91 };
92
93 wrapperFn = function () {
94 if (lock) {
95 // called too soon, queue to call later
96 args = arguments;
97
98 } else {
99 // call and lock until later
100 fn.apply(context, arguments);
101 setTimeout(later, time);
102 lock = true;
103 }
104 };
105
106 return wrapperFn;
107 }
108
109 // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number
110 // Returns the number `num` modulo `range` in such a way so it lies within

Callers 4

leaflet-src.jsFile · 0.70
FGBLayer.jsFile · 0.50
_getGraphConfigMethod · 0.50
_handleFeaturesMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected