This commit is contained in:
Lukáš Kaňka
2023-08-15 18:35:50 +02:00
commit ea3e372146
10019 changed files with 2548539 additions and 0 deletions

3
CyLukTs/lukan/node_modules/throttleit/.npmignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
components
build
node_modules

19
CyLukTs/lukan/node_modules/throttleit/History.md generated vendored Normal file
View File

@ -0,0 +1,19 @@
1.0.0 / 2015-02-27
==================
- Internal refactor
- Removed `max` argument
- Context for invocation is cached/cleared properly
- More tests
0.0.2 / 2013-03-26
==================
- Cache the return value
- Don't use `setTimeout()`
0.0.1 / 2013-03-26
==================
- Initial release

18
CyLukTs/lukan/node_modules/throttleit/Makefile generated vendored Normal file
View File

@ -0,0 +1,18 @@
build: components index.js
@component build --dev
components: component.json
@component install --dev
clean:
rm -fr build components template.js
test: node_modules
@./node_modules/mocha/bin/mocha \
--reporter spec
node_modules: package.json
@npm install
.PHONY: clean

32
CyLukTs/lukan/node_modules/throttleit/Readme.md generated vendored Normal file
View File

@ -0,0 +1,32 @@
# throttle
Throttle a function
## Installation
$ component install component/throttle
## Example
var throttle = require('throttle');
window.onresize = throttle(resize, 200);
function resize(e) {
console.log('height', window.innerHeight);
console.log('width', window.innerWidth);
}
## API
### throttle(fn, wait)
Creates a function that will call `fn` at most once every `wait` milliseconds.
Supports leading and trailing invocation.
`fn` will receive last context (`this`) and last arguments passed to a throttled wrapper before `fn` was invoked.
## License
MIT

13
CyLukTs/lukan/node_modules/throttleit/component.json generated vendored Normal file
View File

@ -0,0 +1,13 @@
{
"name": "throttle",
"repo": "component/throttle",
"description": "Throttle a function",
"version": "0.0.2",
"keywords": [],
"dependencies": {},
"development": {},
"license": "MIT",
"scripts": [
"index.js"
]
}

14
CyLukTs/lukan/node_modules/throttleit/example.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
var throttle = require('./');
function onprogress(n) {
console.log('progress %s%', n);
}
onprogress = throttle(onprogress, 500);
var n = 0;
setInterval(function(){
if (n >= 100) return;
onprogress(n++);
}, 50);

32
CyLukTs/lukan/node_modules/throttleit/index.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
module.exports = throttle;
/**
* Returns a new function that, when invoked, invokes `func` at most once per `wait` milliseconds.
*
* @param {Function} func Function to wrap.
* @param {Number} wait Number of milliseconds that must elapse between `func` invocations.
* @return {Function} A new function that wraps the `func` function passed in.
*/
function throttle (func, wait) {
var ctx, args, rtn, timeoutID; // caching
var last = 0;
return function throttled () {
ctx = this;
args = arguments;
var delta = new Date() - last;
if (!timeoutID)
if (delta >= wait) call();
else timeoutID = setTimeout(call, wait - delta);
return rtn;
};
function call () {
timeoutID = 0;
last = +new Date();
rtn = func.apply(ctx, args);
ctx = null;
args = null;
}
}

22
CyLukTs/lukan/node_modules/throttleit/package.json generated vendored Normal file
View File

@ -0,0 +1,22 @@
{
"name": "throttleit",
"description": "Throttle a function",
"version": "1.0.0",
"keywords": [],
"repository": {
"type": "git",
"url": "git://github.com/component/throttle.git"
},
"devDependencies": {
"mocha": "^1.18.0"
},
"license": "MIT",
"component": {
"scripts": {
"throttle/index.js": "index.js"
}
},
"scripts": {
"test": "mocha --reporter spec"
}
}

73
CyLukTs/lukan/node_modules/throttleit/test.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
var assert = require('assert');
var throttle = require('./');
describe('throttle', function(){
function counter() {
function count(){
count.invoked++;
}
count.invoked = 0;
return count;
}
it('should throttle a function', function(done){
var count = counter();
var wait = 100;
var total = 500;
var fn = throttle(count, wait);
var interval = setInterval(fn, 20);
setTimeout(function(){
clearInterval(interval);
assert(count.invoked === (total / wait));
done();
}, total + 5);
});
it('should call the function last time', function(done){
var count = counter();
var wait = 100;
var fn = throttle(count, wait);
fn();
fn();
assert(count.invoked === 1);
setTimeout(function(){
assert(count.invoked === 2);
done();
}, wait + 5);
});
it('should pass last context', function(done){
var wait = 100;
var ctx;
var fn = throttle(logctx, wait);
var foo = {};
var bar = {};
fn.call(foo);
fn.call(bar);
assert(ctx === foo);
setTimeout(function(){
assert(ctx === bar);
done();
}, wait + 5);
function logctx() {
ctx = this;
}
});
it('should pass last arguments', function(done){
var wait = 100;
var args;
var fn = throttle(logargs, wait);
fn.call(null, 1);
fn.call(null, 2);
assert(args && args[0] === 1);
setTimeout(function(){
assert(args && args[0] === 2);
done();
}, wait + 5);
function logargs() {
args = arguments;
}
});
});