This commit is contained in:
eric sciple 2020-01-24 12:20:19 -05:00
parent beb1329f9f
commit 2b95e76931
7736 changed files with 1874747 additions and 51184 deletions

19
node_modules/throat/LICENSE generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2013 Forbes Lindesay
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.

55
node_modules/throat/README.md generated vendored Normal file
View file

@ -0,0 +1,55 @@
# throat
Throttle the parallelism of an asynchronous, promise returning, function / functions. This has special utility when you set the concurrency to `1`. That way you get a mutually exclusive lock.
[![Build Status](https://img.shields.io/travis/ForbesLindesay/throat/master.svg)](https://travis-ci.org/ForbesLindesay/throat)
[![Coverage Status](https://img.shields.io/coveralls/ForbesLindesay/throat/master.svg?style=flat)](https://coveralls.io/r/ForbesLindesay/throat?branch=master)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/throat.svg)](https://david-dm.org/ForbesLindesay/throat)
[![NPM version](https://img.shields.io/npm/v/throat.svg)](https://www.npmjs.com/package/throat)
[![Greenkeeper badge](https://badges.greenkeeper.io/ForbesLindesay/throat.svg)](https://greenkeeper.io/)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/throat.svg)](https://saucelabs.com/u/throat)
## Installation
npm install throat
## API
### throat(concurrency)
This returns a function that acts a bit like a lock (exactly as a lock if concurrency is 1).
Example, only 2 of the following functions will execute at any one time:
```js
const throat = require('throat')(2);
// alternatively provide your own promise implementation
const throat = require('throat')(require('promise'))(2);
const promise = Promise.resolve();
const resA = throat(() => /* async stuff... */ promise);
const resB = throat(() => /* async stuff... */ promise);
const resC = throat(() => /* async stuff... */ promise);
const resD = throat(() => /* async stuff... */ promise);
const resE = throat(() => /* async stuff... */ promise);
```
### throat(concurrency, worker)
This returns a function that is an exact copy of `worker` except that it will only execute up to `concurrency` times in parallel before further requests are queued:
```js
const throat = require('throat');
// alternatively provide your own promise implementation
const throat = require('throat')(require('promise'));
const input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt'];
const data = Promise.all(input.map(throat(2, fileName => readFile(fileName))));
```
Only 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.
## License
MIT

5
node_modules/throat/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
declare function throat<TResult, TFn extends (...args: Array<any>) => Promise<TResult>>(size: number, fn: TFn): TFn;
declare function throat<TResult, TFn extends (...args: Array<any>) => Promise<TResult>>(fn: TFn, size: number): TFn;
declare function throat(size: number): <TResult>(fn: () => Promise<TResult>) => Promise<TResult>;
export = throat;

116
node_modules/throat/index.js generated vendored Normal file
View file

@ -0,0 +1,116 @@
'use strict';
module.exports = function (PromiseArgument) {
var Promise;
function throat(size, fn) {
var queue = new Queue();
function run(fn, self, args) {
if (size) {
size--;
var result = new Promise(function (resolve) {
resolve(fn.apply(self, args));
});
result.then(release, release);
return result;
} else {
return new Promise(function (resolve) {
queue.push(new Delayed(resolve, fn, self, args));
});
}
}
function release() {
size++;
if (!queue.isEmpty()) {
var next = queue.shift();
next.resolve(run(next.fn, next.self, next.args));
}
}
if (typeof size === 'function') {
var temp = fn;
fn = size;
size = temp;
}
if (typeof size !== 'number') {
throw new TypeError(
'Expected throat size to be a number but got ' + typeof size
);
}
if (fn !== undefined && typeof fn !== 'function') {
throw new TypeError(
'Expected throat fn to be a function but got ' + typeof fn
);
}
if (typeof fn === 'function') {
return function () {
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
return run(fn, this, args);
};
} else {
return function (fn) {
if (typeof fn !== 'function') {
throw new TypeError(
'Expected throat fn to be a function but got ' + typeof fn
);
}
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
return run(fn, this, args);
};
}
}
if (arguments.length === 1 && typeof PromiseArgument === 'function') {
Promise = PromiseArgument;
return throat;
} else {
Promise = module.exports.Promise;
if (typeof Promise !== 'function') {
throw new Error(
'You must provide a Promise polyfill for this library to work in older environments'
);
}
return throat(arguments[0], arguments[1]);
}
};
/* istanbul ignore next */
if (typeof Promise === 'function') {
module.exports.Promise = Promise;
}
function Delayed(resolve, fn, self, args) {
this.resolve = resolve;
this.fn = fn;
this.self = self || null;
this.args = args;
}
function Queue() {
this._s1 = [];
this._s2 = [];
}
Queue.prototype.push = function (value) {
this._s1.push(value);
};
Queue.prototype.shift = function () {
var s2 = this._s2;
if (s2.length === 0) {
var s1 = this._s1;
if (s1.length === 0) {
return;
}
this._s1 = s2;
s2 = this._s2 = s1.reverse();
}
return s2.pop();
};
Queue.prototype.isEmpty = function () {
return !this._s1.length && !this._s2.length;
};

7
node_modules/throat/index.js.flow generated vendored Normal file
View file

@ -0,0 +1,7 @@
// @flow
declare function throat<TResult, TFn: (...args: Array<any>) => Promise<TResult>>(size: number, fn: TFn): TFn;
declare function throat<TResult, TFn: (...args: Array<any>) => Promise<TResult>>(fn: TFn, size: number): TFn;
declare function throat(size: number): <TResult>(fn: () => Promise<TResult>) => Promise<TResult>;
module.exports = throat;

82
node_modules/throat/package.json generated vendored Normal file
View file

@ -0,0 +1,82 @@
{
"_args": [
[
"throat@4.1.0",
"/Users/eric/repos/actions/setup-node"
]
],
"_development": true,
"_from": "throat@4.1.0",
"_id": "throat@4.1.0",
"_inBundle": false,
"_integrity": "sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=",
"_location": "/throat",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "throat@4.1.0",
"name": "throat",
"escapedName": "throat",
"rawSpec": "4.1.0",
"saveSpec": null,
"fetchSpec": "4.1.0"
},
"_requiredBy": [
"/jest-changed-files",
"/jest-circus",
"/jest-jasmine2",
"/jest-runner"
],
"_resolved": "https://registry.npmjs.org/throat/-/throat-4.1.0.tgz",
"_spec": "4.1.0",
"_where": "/Users/eric/repos/actions/setup-node",
"author": {
"name": "ForbesLindesay"
},
"bugs": {
"url": "https://github.com/ForbesLindesay/throat/issues"
},
"description": "Throttle the parallelism of an asynchronous (promise returning) function / functions",
"devDependencies": {
"coveralls": "^2.11.2",
"flow-bin": "^0.49.1",
"istanbul": "^0.4.5",
"jest": "^20.0.4",
"promise": "^8.0.0",
"sauce-test": "^1.0.0",
"test-result": "^2.0.0",
"testit": "^2.1.3",
"typescript": "^2.3.4"
},
"files": [
"index.d.ts",
"index.js",
"index.js.flow"
],
"homepage": "https://github.com/ForbesLindesay/throat#readme",
"keywords": [
"promise",
"aplus",
"then",
"throttle",
"concurrency",
"parallelism",
"limit"
],
"license": "MIT",
"name": "throat",
"repository": {
"type": "git",
"url": "git+https://github.com/ForbesLindesay/throat.git"
},
"scripts": {
"coverage": "istanbul cover test/index.js",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"flow": "flow",
"test": "node test/index.js && npm run test:types && node test/browser.js",
"test:types": "jest",
"tsc": "tsc --noEmit"
},
"version": "4.1.0"
}