Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn
2017-05-17 13:45:25 -04:00
parent 415b9c25f3
commit 7efe7605b8
11476 changed files with 2170865 additions and 34 deletions

14
node_modules/throat/.npmignore generated vendored Normal file
View File

@ -0,0 +1,14 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
npm-debug.log
node_modules
coverage

10
node_modules/throat/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,10 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs-1.1"
# Use faster Docker architecture on Travis.
sudo: false
script: "npm test && npm run coveralls"

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.

74
node_modules/throat/README.md generated vendored Normal file
View File

@ -0,0 +1,74 @@
# 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/gemnasium/ForbesLindesay/throat.svg)](https://gemnasium.com/ForbesLindesay/throat)
[![NPM version](https://img.shields.io/npm/v/throat.svg)](http://badge.fury.io/js/throat)
[![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
// with polyfill or in iojs
require('promise/polyfill')
var throat = require('throat')(2)
// alternatively provide your own promise implementation
var throat = require('throat')(require('promise'))(2)
var resA = throat(function () {
//async stuff
return promise
})
var resA = throat(function () {
//async stuff
return promise
})
var resA = throat(function () {
//async stuff
return promise
})
var resA = throat(function () {
//async stuff
return promise
})
var resA = throat(function () {
//async stuff
return 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
// with polyfill or in iojs
require('promise/polyfill')
var throat = require('throat')
// alternatively provide your own promise implementation
var throat = require('throat')(require('promise'))
var input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt']
var data = Promise.all(input.map(throat(2, function (fileName) {
return readFile(fileName)
})))
```
Only 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.
## License
MIT

73
node_modules/throat/index.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
'use strict'
module.exports = function (PromiseArgument) {
var Promise;
function throat(size, fn) {
var 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.length) {
var next = queue.shift()
next.resolve(run(next.fn, next.self, next.args))
}
}
if (typeof size === 'function' && typeof fn === 'number') {
var temp = fn;
fn = size;
size = temp;
}
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) {
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
return run(fn, this, args)
}
}
}
if (typeof arguments[0] === 'number' || typeof arguments[1] === 'number') {
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]);
} else {
Promise = PromiseArgument;
return throat;
}
}
/* 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
}

86
node_modules/throat/package.json generated vendored Normal file
View File

@ -0,0 +1,86 @@
{
"_args": [
[
"throat@^2.0.2",
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\typings-core"
]
],
"_from": "throat@>=2.0.2-0 <3.0.0-0",
"_id": "throat@2.0.2",
"_inCache": true,
"_location": "/throat",
"_npmUser": {
"email": "forbes@lindesay.co.uk",
"name": "forbeslindesay"
},
"_npmVersion": "1.4.28",
"_phantomChildren": {},
"_requested": {
"name": "throat",
"raw": "throat@^2.0.2",
"rawSpec": "^2.0.2",
"scope": null,
"spec": ">=2.0.2-0 <3.0.0-0",
"type": "range"
},
"_requiredBy": [
"/typings-core"
],
"_resolved": "https://registry.npmjs.org/throat/-/throat-2.0.2.tgz",
"_shasum": "a9fce808b69e133a632590780f342c30a6249b02",
"_shrinkwrap": null,
"_spec": "throat@^2.0.2",
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\typings-core",
"author": {
"name": "ForbesLindesay"
},
"bugs": {
"url": "https://github.com/ForbesLindesay/throat/issues"
},
"dependencies": {},
"description": "Throttle the parallelism of an asynchronous (promise returning) function / functions",
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.5",
"promise": "^6.1.0",
"sauce-test": "^1.0.0",
"test-result": "^2.0.0",
"testit": "^2.0.2"
},
"directories": {},
"dist": {
"shasum": "a9fce808b69e133a632590780f342c30a6249b02",
"tarball": "https://registry.npmjs.org/throat/-/throat-2.0.2.tgz"
},
"gitHead": "4cb485f83e0521d661aaaac02162138686bc3908",
"homepage": "https://github.com/ForbesLindesay/throat",
"installable": true,
"keywords": [
"aplus",
"concurrency",
"limit",
"parallelism",
"promise",
"then",
"throttle"
],
"license": "MIT",
"maintainers": [
{
"name": "forbeslindesay",
"email": "forbes@lindesay.co.uk"
}
],
"name": "throat",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/ForbesLindesay/throat.git"
},
"scripts": {
"coverage": "istanbul cover test/index.js",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"test": "node test/index.js && node test/browser.js"
},
"version": "2.0.2"
}

45
node_modules/throat/test/browser.js generated vendored Normal file
View File

@ -0,0 +1,45 @@
'use strict';
var run = require('sauce-test');
var testResult = require('test-result');
var LOCAL = !process.env.CI && process.argv[2] !== 'sauce';
var USER = 'throat';
var ACCESS_KEY = '57db1bf4-537a-4bde-ab8b-1e82eed9db4b';
if (process.env.CI && process.version.indexOf('v0.12.') !== 0) {
// only run the browser tests once
process.exit(0);
}
run(__dirname + '/index.js', LOCAL ? 'chromedriver' : 'saucelabs', {
username: USER,
accessKey: ACCESS_KEY,
browserify: true,
disableSSL: true,
filterPlatforms: function (platform, defaultFilter) {
// exclude some arbitrary browsers to make tests
// run faster. Also excludes beta versions of browsers
if (!defaultFilter(platform)) return false;
// these platforms don't support ES5
var version = +platform.version;
switch (platform.browserName) {
case 'internet explorer':
return version > 8;
case 'firefox':
return version > 4;
case 'iphone':
case 'ipad':
return version > 5.1;
default:
return true;
}
},
bail: true,
timeout: '30s'
}).done(function (result) {
if (result.passed) {
testResult.pass('browser tests');
} else {
testResult.fail('browser tests');
}
});

245
node_modules/throat/test/index.js generated vendored Normal file
View File

@ -0,0 +1,245 @@
'use strict';
var assert = require('assert');
var fs = require('fs');
var test = require('testit');
var Promise = require('promise/lib/es6-extensions.js');
var throat = require('../')(Promise);
var sentA = {}, sentB = {}, sentC = {}
function job() {
var resolve, reject;
var promise = new Promise(function (_resolve, _reject) {
resolve = _resolve;
reject = _reject;
});
function executeJob() {
if (executeJob.isRun) throw new Error('Job was run multiple times');
executeJob.isRun = true;
executeJob.args = Array.prototype.slice.call(arguments);
return promise;
}
executeJob.fail = function (err) {
reject(err);
};
executeJob.complete = function (val) {
resolve(val);
};
executeJob.isRun = false
return executeJob;
}
function Processed(val) {
this.val = val
}
function worker(max) {
var concurrent = 0
function execute() {
concurrent++
if (concurrent > max) throw new Error('Extra processes were run in parallel.')
var res = new Processed(Array.prototype.slice.call(arguments))
return new Promise(function (resolve) {
setTimeout(function () {
concurrent--
resolve(res)
}, 100)
})
}
return execute
}
test('throat(n)', function () {
test('throat(1) acts as a lock', function (done) {
var lock = throat(1)
var a = job(), b = job(), c = job();
var resA = lock(a, 123)
var resB = lock(b, 456)
var resC = lock(c, 789)
assert(a.isRun)
assert(!b.isRun)
assert(!c.isRun)
a.complete(sentA)
resA.then(function (resA) {
assert(resA === sentA)
assert(a.isRun)
assert(b.isRun)
assert(!c.isRun)
b.fail(sentB)
return resB
.then(function () {
throw new Error('b should have been rejected')
}, function (errB) {
assert(errB === sentB)
})
})
.then(function () {
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
assert.deepEqual(a.args, [123]);
assert.deepEqual(b.args, [456]);
assert.deepEqual(c.args, [789]);
c.complete(sentC)
return resC
})
.then(function (resC) {
assert(resC === sentC)
})
.nodeify(done)
})
test('throat(2) lets two processes acquire the same lock', function (done) {
var lock = throat(2)
var a = job(), b = job(), c = job();
var resA = lock(a)
var resB = lock(b)
var resC = lock(c)
assert(a.isRun)
assert(b.isRun)
assert(!c.isRun)
a.complete(sentA)
resA.then(function (resA) {
assert(resA === sentA)
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
b.fail(sentB)
return resB
.then(function () {
throw new Error('b should have been rejected')
}, function (errB) {
assert(errB === sentB)
})
})
.then(function () {
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
c.complete(sentC)
return resC
})
.then(function (resC) {
assert(resC === sentC)
})
.nodeify(done)
})
test('throat(3) lets three processes acquire the same lock', function (done) {
var lock = throat(3)
var a = job(), b = job(), c = job();
var resA = lock(a)
var resB = lock(b)
var resC = lock(c)
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
a.complete(sentA)
resA.then(function (resA) {
assert(resA === sentA)
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
b.fail(sentB)
return resB
.then(function () {
throw new Error('b should have been rejected')
}, function (errB) {
assert(errB === sentB)
})
})
.then(function () {
assert(a.isRun)
assert(b.isRun)
assert(c.isRun)
c.complete(sentC)
return resC
})
.then(function (resC) {
assert(resC === sentC)
})
.nodeify(done)
})
})
test('throat(n, fn)', function () {
test('throat(1, fn) acts as a sequential worker', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(1, worker(1))))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
test('throat(2, fn) works on two inputs in parallel', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(2, worker(2))))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
test('throat(3, fn) works on three inputs in parallel', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(3, worker(3))))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
})
test('throat(fn, n)', function () {
test('throat(fn, 1) acts as a sequential worker', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(worker(1), 1)))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
test('throat(fn, 2) works on two inputs in parallel', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(worker(2), 2)))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
test('throat(fn, 3) works on three inputs in parallel', function (done) {
Promise.all([sentA, sentB, sentC].map(throat(worker(3), 3)))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
})
test('with native promises', function (done) {
var throat = require('../')
throat.Promise = Promise
Promise.all([sentA, sentB, sentC].map(throat(1, worker(1))))
.then(function (res) {
assert(res[0] instanceof Processed && res[0].val.length > 1 && res[0].val[0] === sentA)
assert(res[1] instanceof Processed && res[1].val.length > 1 && res[1].val[0] === sentB)
assert(res[2] instanceof Processed && res[2].val.length > 1 && res[2].val[0] === sentC)
})
.nodeify(done)
})
test('without native promises', function () {
var throat = require('../')
throat.Promise = null
try {
throat(1)
} catch (ex) {
assert(/provide a Promise polyfill/.test(ex.message));
return;
}
throw new Error('Expected a failure');
})