/usr/share/javascript/yui3/yui-throttle/yui-throttle.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('yui-throttle', function(Y) {
/**
Throttles a call to a method based on the time between calls. This method is attached
to the `Y` object and is <a href="../classes/YUI.html#method_throttle">documented there</a>.
var fn = Y.throttle(function() {
counter++;
});
for (i; i< 35000; i++) {
out++;
fn();
}
@module yui
@submodule yui-throttle
*/
/*! Based on work by Simon Willison: http://gist.github.com/292562 */
/**
* Throttles a call to a method based on the time between calls.
* @method throttle
* @for YUI
* @param fn {function} The function call to throttle.
* @param ms {int} The number of milliseconds to throttle the method call.
* Can set globally with Y.config.throttleTime or by call. Passing a -1 will
* disable the throttle. Defaults to 150.
* @return {function} Returns a wrapped function that calls fn throttled.
* @since 3.1.0
*/
Y.throttle = function(fn, ms) {
ms = (ms) ? ms : (Y.config.throttleTime || 150);
if (ms === -1) {
return (function() {
fn.apply(null, arguments);
});
}
var last = Y.Lang.now();
return (function() {
var now = Y.Lang.now();
if (now - last > ms) {
last = now;
fn.apply(null, arguments);
}
});
};
}, '3.5.1' ,{requires:['yui-base']});
|