mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 21:04:45 +00:00
.
This commit is contained in:
parent
fc725ba36b
commit
422b9fdb15
7395 changed files with 1786235 additions and 3476 deletions
7
node_modules/async-limiter/.travis.yml
generated
vendored
Normal file
7
node_modules/async-limiter/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
- "node"
|
||||
script: npm run travis
|
||||
cache:
|
||||
yarn: true
|
8
node_modules/async-limiter/LICENSE
generated
vendored
Normal file
8
node_modules/async-limiter/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
The MIT License (MIT)
|
||||
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
67
node_modules/async-limiter/index.js
generated
vendored
Normal file
67
node_modules/async-limiter/index.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
'use strict';
|
||||
|
||||
function Queue(options) {
|
||||
if (!(this instanceof Queue)) {
|
||||
return new Queue(options);
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
this.concurrency = options.concurrency || Infinity;
|
||||
this.pending = 0;
|
||||
this.jobs = [];
|
||||
this.cbs = [];
|
||||
this._done = done.bind(this);
|
||||
}
|
||||
|
||||
var arrayAddMethods = [
|
||||
'push',
|
||||
'unshift',
|
||||
'splice'
|
||||
];
|
||||
|
||||
arrayAddMethods.forEach(function(method) {
|
||||
Queue.prototype[method] = function() {
|
||||
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
||||
this._run();
|
||||
return methodResult;
|
||||
};
|
||||
});
|
||||
|
||||
Object.defineProperty(Queue.prototype, 'length', {
|
||||
get: function() {
|
||||
return this.pending + this.jobs.length;
|
||||
}
|
||||
});
|
||||
|
||||
Queue.prototype._run = function() {
|
||||
if (this.pending === this.concurrency) {
|
||||
return;
|
||||
}
|
||||
if (this.jobs.length) {
|
||||
var job = this.jobs.shift();
|
||||
this.pending++;
|
||||
job(this._done);
|
||||
this._run();
|
||||
}
|
||||
|
||||
if (this.pending === 0) {
|
||||
while (this.cbs.length !== 0) {
|
||||
var cb = this.cbs.pop();
|
||||
process.nextTick(cb);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Queue.prototype.onDone = function(cb) {
|
||||
if (typeof cb === 'function') {
|
||||
this.cbs.push(cb);
|
||||
this._run();
|
||||
}
|
||||
};
|
||||
|
||||
function done() {
|
||||
this.pending--;
|
||||
this._run();
|
||||
}
|
||||
|
||||
module.exports = Queue;
|
39
node_modules/async-limiter/package.json
generated
vendored
Normal file
39
node_modules/async-limiter/package.json
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "async-limiter",
|
||||
"version": "1.0.0",
|
||||
"description": "asynchronous function queue with adjustable concurrency",
|
||||
"keywords": [
|
||||
"throttle",
|
||||
"async",
|
||||
"limiter",
|
||||
"asynchronous",
|
||||
"job",
|
||||
"task",
|
||||
"concurrency",
|
||||
"concurrent"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.2",
|
||||
"eslint": "^4.6.1",
|
||||
"eslint-plugin-mocha": "^4.11.0",
|
||||
"intelli-espower-loader": "^1.0.1",
|
||||
"istanbul": "^0.3.2",
|
||||
"mocha": "^3.5.2",
|
||||
"power-assert": "^1.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --R intelli-espower-loader test/",
|
||||
"travis": "npm run lint && npm run coverage",
|
||||
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls",
|
||||
"example": "node example",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"repository": "https://github.com/strml/async-limiter.git",
|
||||
"author": "Samuel Reed <samuel.trace.reed@gmail.com",
|
||||
"license": "MIT"
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz"
|
||||
,"_integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
|
||||
,"_from": "async-limiter@1.0.0"
|
||||
}
|
132
node_modules/async-limiter/readme.md
generated
vendored
Normal file
132
node_modules/async-limiter/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
# Async-Limiter
|
||||
|
||||
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
|
||||
|
||||
[](http://www.npmjs.org/async-limiter)
|
||||
[](https://travis-ci.org/STRML/async-limiter)
|
||||
[](https://coveralls.io/r/STRML/async-limiter)
|
||||
|
||||
This module exports a class `Limiter` that implements some of the `Array` API.
|
||||
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
|
||||
|
||||
## Motivation
|
||||
|
||||
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
|
||||
run at infinite concurrency.
|
||||
|
||||
In this case, it is actually faster, and takes far less memory, to limit concurrency.
|
||||
|
||||
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
|
||||
make this module faster or lighter, but new functionality is not desired.
|
||||
|
||||
Style should confirm to nodejs/node style.
|
||||
|
||||
## Example
|
||||
|
||||
``` javascript
|
||||
var Limiter = require('async-limiter')
|
||||
|
||||
var t = new Limiter({concurrency: 2});
|
||||
var results = []
|
||||
|
||||
// add jobs using the familiar Array API
|
||||
t.push(function (cb) {
|
||||
results.push('two')
|
||||
cb()
|
||||
})
|
||||
|
||||
t.push(
|
||||
function (cb) {
|
||||
results.push('four')
|
||||
cb()
|
||||
},
|
||||
function (cb) {
|
||||
results.push('five')
|
||||
cb()
|
||||
}
|
||||
)
|
||||
|
||||
t.unshift(function (cb) {
|
||||
results.push('one')
|
||||
cb()
|
||||
})
|
||||
|
||||
t.splice(2, 0, function (cb) {
|
||||
results.push('three')
|
||||
cb()
|
||||
})
|
||||
|
||||
// Jobs run automatically. If you want a callback when all are done,
|
||||
// call 'onDone()'.
|
||||
t.onDone(function () {
|
||||
console.log('all done:', results)
|
||||
})
|
||||
```
|
||||
|
||||
## Zlib Example
|
||||
|
||||
```js
|
||||
const zlib = require('zlib');
|
||||
const Limiter = require('async-limiter');
|
||||
|
||||
const message = {some: "data"};
|
||||
const payload = new Buffer(JSON.stringify(message));
|
||||
|
||||
// Try with different concurrency values to see how this actually
|
||||
// slows significantly with higher concurrency!
|
||||
//
|
||||
// 5: 1398.607ms
|
||||
// 10: 1375.668ms
|
||||
// Infinity: 4423.300ms
|
||||
//
|
||||
const t = new Limiter({concurrency: 5});
|
||||
function deflate(payload, cb) {
|
||||
t.push(function(done) {
|
||||
zlib.deflate(payload, function(err, buffer) {
|
||||
done();
|
||||
cb(err, buffer);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.time('deflate');
|
||||
for(let i = 0; i < 30000; ++i) {
|
||||
deflate(payload, function (err, buffer) {});
|
||||
}
|
||||
q.onDone(function() {
|
||||
console.timeEnd('deflate');
|
||||
});
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
`npm install async-limiter`
|
||||
|
||||
## Test
|
||||
|
||||
`npm test`
|
||||
|
||||
## API
|
||||
|
||||
### `var t = new Limiter([opts])`
|
||||
Constructor. `opts` may contain inital values for:
|
||||
* `q.concurrency`
|
||||
|
||||
## Instance methods
|
||||
|
||||
### `q.onDone(fn)`
|
||||
`fn` will be called once and only once, when the queue is empty.
|
||||
|
||||
## Instance methods mixed in from `Array`
|
||||
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
||||
### `q.push(element1, ..., elementN)`
|
||||
### `q.unshift(element1, ..., elementN)`
|
||||
### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
|
||||
|
||||
## Properties
|
||||
### `q.concurrency`
|
||||
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
|
||||
|
||||
### `q.length`
|
||||
Jobs pending + jobs to process (readonly).
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue