08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

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

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

19
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
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
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
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
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
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;
}
}

180
node_modules/throttleit/package.json generated vendored Normal file
View File

@@ -0,0 +1,180 @@
{
"_args": [
[
{
"name": "throttleit",
"raw": "throttleit@^1.0.0",
"rawSpec": "^1.0.0",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"/root/gitbook/node_modules/request-progress"
]
],
"_from": "throttleit@>=1.0.0 <2.0.0",
"_id": "throttleit@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/throttleit",
"_nodeVersion": "1.0.2",
"_npmUser": {
"email": "dominic@dbarnes.info",
"name": "dominicbarnes"
},
"_npmVersion": "2.1.18",
"_phantomChildren": {},
"_requested": {
"name": "throttleit",
"raw": "throttleit@^1.0.0",
"rawSpec": "^1.0.0",
"scope": null,
"spec": ">=1.0.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/request-progress"
],
"_resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz",
"_shasum": "9e785836daf46743145a5984b6268d828528ac6c",
"_shrinkwrap": null,
"_spec": "throttleit@^1.0.0",
"_where": "/root/gitbook/node_modules/request-progress",
"bugs": {
"url": "https://github.com/component/throttle/issues"
},
"component": {
"scripts": {
"throttle/index.js": "index.js"
}
},
"dependencies": {},
"description": "Throttle a function",
"devDependencies": {
"mocha": "^1.18.0"
},
"dist": {
"integrity": "sha512-rkTVqu6IjfQ/6+uNuuc3sZek4CEYxTJom3IktzgdSxcZqdARuebbA/f4QmAxMQIxqq9ZLEUkSYqvuk1I6VKq4g==",
"shasum": "9e785836daf46743145a5984b6268d828528ac6c",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQDPs5wQXhynuqlFVR8t6gFzaybkCkDhkW+shKwWosrdGgIgTmvdus4kygJHK+irT8/qvLOIDxwRfuEwFj5/SMRDdSE="
}
],
"tarball": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz"
},
"gitHead": "19f9fd95782d372f2d0be6d5c60d60f8176d7ef8",
"homepage": "https://github.com/component/throttle",
"keywords": [],
"license": "MIT",
"maintainers": [
{
"email": "tj@vision-media.ca",
"name": "tjholowaychuk"
},
{
"email": "nathan@tootallnate.net",
"name": "tootallnate"
},
{
"email": "rauchg@gmail.com",
"name": "rauchg"
},
{
"email": "rdsuarez@gmail.com",
"name": "retrofox"
},
{
"email": "thecoreh@gmail.com",
"name": "coreh"
},
{
"email": "forbes@lindesay.co.uk",
"name": "forbeslindesay"
},
{
"email": "kelonyemitchel@gmail.com",
"name": "kelonye"
},
{
"email": "mattmuelle@gmail.com",
"name": "mattmueller"
},
{
"email": "yields@icloud.com",
"name": "yields"
},
{
"email": "antshort@gmail.com",
"name": "anthonyshort"
},
{
"email": "jonathanrichardong@gmail.com",
"name": "jongleberry"
},
{
"email": "ian@ianstormtaylor.com",
"name": "ianstormtaylor"
},
{
"email": "cristian@gravityonmars.com",
"name": "cristiandouce"
},
{
"email": "arpad.borsos@googlemail.com",
"name": "swatinem"
},
{
"email": "gstagas@gmail.com",
"name": "stagas"
},
{
"email": "amjad.masad@gmail.com",
"name": "amasad"
},
{
"email": "julian@juliangruber.com",
"name": "juliangruber"
},
{
"email": "shtylman@gmail.com",
"name": "shtylman"
},
{
"email": "calvin@calv.info",
"name": "calvinfo"
},
{
"email": "dominic@dbarnes.info",
"name": "dominicbarnes"
},
{
"email": "me@stephenmathieson.com",
"name": "stephenmathieson"
},
{
"email": "trevorgerhardt@gmail.com",
"name": "trevorgerhardt"
},
{
"email": "timaschew@gmail.com",
"name": "timaschew"
},
{
"email": "hughskennedy@gmail.com",
"name": "hughsk"
}
],
"name": "throttleit",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/component/throttle.git"
},
"scripts": {
"test": "mocha --reporter spec"
},
"version": "1.0.0"
}

73
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;
}
});
});