Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
19 lines
No EOL
467 B
JavaScript
Executable file
19 lines
No EOL
467 B
JavaScript
Executable file
define(function(require, exports, module) {
|
|
'use strict';
|
|
|
|
module.exports = function(func, wait, immediate) {
|
|
var timeout;
|
|
return function() {
|
|
var context = this, args = arguments;
|
|
var later = function() {
|
|
timeout = null;
|
|
if (!immediate) { func.apply(context, args); }
|
|
};
|
|
var callNow = immediate && !timeout;
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(later, wait);
|
|
if (callNow) { func.apply(context, args); }
|
|
};
|
|
};
|
|
|
|
}); |