In the first statement util.js and export functions
function throttle(fn, gapTime) { if (gapTime == null || gapTime == undefined) { gapTime = 1500 } let _lastTime = null // returns the new function return function () { let _nowTime = + new Date() if (_nowTime - _lastTime > gapTime || !_lastTime) { fn.apply ( this , arguments) // The parameters passed to the original function and this _lastTime = _nowTime } } }
module.exports ={ throttle: throttle }
Js required page in the document introduction var util = require ( '')
tap: util.throttle(function (e) { // function on their own needs }, 1000) // interval 1000