flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
317
BACK_BACK/node_modules/promise-queue/.csscomb.json
generated
vendored
Executable file
317
BACK_BACK/node_modules/promise-queue/.csscomb.json
generated
vendored
Executable file
|
|
@ -0,0 +1,317 @@
|
|||
{
|
||||
"exclude": [
|
||||
".*",
|
||||
"node_modules/**"
|
||||
],
|
||||
"always-semicolon": true,
|
||||
"block-indent": true,
|
||||
"colon-space": true,
|
||||
"color-case": "lower",
|
||||
"color-shorthand": true,
|
||||
"element-case": "lower",
|
||||
"leading-zero": false,
|
||||
"rule-indent": true,
|
||||
"stick-brace": "\n",
|
||||
"strip-spaces": true,
|
||||
"unitless-zero": true,
|
||||
"sort-order": [
|
||||
[
|
||||
"font",
|
||||
"font-family",
|
||||
"font-size",
|
||||
"font-weight",
|
||||
"font-style",
|
||||
"font-variant",
|
||||
"font-size-adjust",
|
||||
"font-stretch",
|
||||
"font-effect",
|
||||
"font-emphasize",
|
||||
"font-emphasize-position",
|
||||
"font-emphasize-style",
|
||||
"font-smooth",
|
||||
"line-height"
|
||||
],
|
||||
[
|
||||
"position",
|
||||
"z-index",
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
[
|
||||
"display",
|
||||
"visibility",
|
||||
"float",
|
||||
"clear",
|
||||
"overflow",
|
||||
"overflow-x",
|
||||
"overflow-y",
|
||||
"-ms-overflow-x",
|
||||
"-ms-overflow-y",
|
||||
"clip",
|
||||
"zoom",
|
||||
"flex-direction",
|
||||
"flex-order",
|
||||
"flex-pack",
|
||||
"flex-align"
|
||||
],
|
||||
[
|
||||
"-webkit-box-sizing",
|
||||
"-moz-box-sizing",
|
||||
"box-sizing",
|
||||
"width",
|
||||
"min-width",
|
||||
"max-width",
|
||||
"height",
|
||||
"min-height",
|
||||
"max-height",
|
||||
"margin",
|
||||
"margin-top",
|
||||
"margin-right",
|
||||
"margin-bottom",
|
||||
"margin-left",
|
||||
"padding",
|
||||
"padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left"
|
||||
],
|
||||
[
|
||||
"table-layout",
|
||||
"empty-cells",
|
||||
"caption-side",
|
||||
"border-spacing",
|
||||
"border-collapse",
|
||||
"list-style",
|
||||
"list-style-position",
|
||||
"list-style-type",
|
||||
"list-style-image"
|
||||
],
|
||||
[
|
||||
"content",
|
||||
"quotes",
|
||||
"counter-reset",
|
||||
"counter-increment",
|
||||
"resize",
|
||||
"cursor",
|
||||
"-webkit-user-select",
|
||||
"-moz-user-select",
|
||||
"-ms-user-select",
|
||||
"user-select",
|
||||
"nav-index",
|
||||
"nav-up",
|
||||
"nav-right",
|
||||
"nav-down",
|
||||
"nav-left",
|
||||
"-webkit-transition",
|
||||
"-moz-transition",
|
||||
"-ms-transition",
|
||||
"-o-transition",
|
||||
"transition",
|
||||
"-webkit-transition-delay",
|
||||
"-moz-transition-delay",
|
||||
"-ms-transition-delay",
|
||||
"-o-transition-delay",
|
||||
"transition-delay",
|
||||
"-webkit-transition-timing-function",
|
||||
"-moz-transition-timing-function",
|
||||
"-ms-transition-timing-function",
|
||||
"-o-transition-timing-function",
|
||||
"transition-timing-function",
|
||||
"-webkit-transition-duration",
|
||||
"-moz-transition-duration",
|
||||
"-ms-transition-duration",
|
||||
"-o-transition-duration",
|
||||
"transition-duration",
|
||||
"-webkit-transition-property",
|
||||
"-moz-transition-property",
|
||||
"-ms-transition-property",
|
||||
"-o-transition-property",
|
||||
"transition-property",
|
||||
"-webkit-transform",
|
||||
"-moz-transform",
|
||||
"-ms-transform",
|
||||
"-o-transform",
|
||||
"transform",
|
||||
"-webkit-transform-origin",
|
||||
"-moz-transform-origin",
|
||||
"-ms-transform-origin",
|
||||
"-o-transform-origin",
|
||||
"transform-origin",
|
||||
"-webkit-animation",
|
||||
"-moz-animation",
|
||||
"-ms-animation",
|
||||
"-o-animation",
|
||||
"animation",
|
||||
"-webkit-animation-name",
|
||||
"-moz-animation-name",
|
||||
"-ms-animation-name",
|
||||
"-o-animation-name",
|
||||
"animation-name",
|
||||
"-webkit-animation-duration",
|
||||
"-moz-animation-duration",
|
||||
"-ms-animation-duration",
|
||||
"-o-animation-duration",
|
||||
"animation-duration",
|
||||
"-webkit-animation-play-state",
|
||||
"-moz-animation-play-state",
|
||||
"-ms-animation-play-state",
|
||||
"-o-animation-play-state",
|
||||
"animation-play-state",
|
||||
"-webkit-animation-timing-function",
|
||||
"-moz-animation-timing-function",
|
||||
"-ms-animation-timing-function",
|
||||
"-o-animation-timing-function",
|
||||
"animation-timing-function",
|
||||
"-webkit-animation-delay",
|
||||
"-moz-animation-delay",
|
||||
"-ms-animation-delay",
|
||||
"-o-animation-delay",
|
||||
"animation-delay",
|
||||
"-webkit-animation-iteration-count",
|
||||
"-moz-animation-iteration-count",
|
||||
"-ms-animation-iteration-count",
|
||||
"-o-animation-iteration-count",
|
||||
"animation-iteration-count",
|
||||
"-webkit-animation-direction",
|
||||
"-moz-animation-direction",
|
||||
"-ms-animation-direction",
|
||||
"-o-animation-direction",
|
||||
"animation-direction",
|
||||
"text-align",
|
||||
"-webkit-text-align-last",
|
||||
"-moz-text-align-last",
|
||||
"-ms-text-align-last",
|
||||
"text-align-last",
|
||||
"vertical-align",
|
||||
"white-space",
|
||||
"text-decoration",
|
||||
"text-emphasis",
|
||||
"text-emphasis-color",
|
||||
"text-emphasis-style",
|
||||
"text-emphasis-position",
|
||||
"text-indent",
|
||||
"-ms-text-justify",
|
||||
"text-justify",
|
||||
"letter-spacing",
|
||||
"word-spacing",
|
||||
"-ms-writing-mode",
|
||||
"text-outline",
|
||||
"text-transform",
|
||||
"text-wrap",
|
||||
"text-overflow",
|
||||
"-ms-text-overflow",
|
||||
"text-overflow-ellipsis",
|
||||
"text-overflow-mode",
|
||||
"-ms-word-wrap",
|
||||
"word-wrap",
|
||||
"word-break",
|
||||
"-ms-word-break",
|
||||
"-moz-tab-size",
|
||||
"-o-tab-size",
|
||||
"tab-size",
|
||||
"-webkit-hyphens",
|
||||
"-moz-hyphens",
|
||||
"hyphens",
|
||||
"pointer-events"
|
||||
],
|
||||
[
|
||||
"opacity",
|
||||
"filter:progid:DXImageTransform.Microsoft.Alpha(Opacity",
|
||||
"-ms-filter:\'progid:DXImageTransform.Microsoft.Alpha",
|
||||
"-ms-interpolation-mode",
|
||||
"color",
|
||||
"border",
|
||||
"border-width",
|
||||
"border-style",
|
||||
"border-color",
|
||||
"border-top",
|
||||
"border-top-width",
|
||||
"border-top-style",
|
||||
"border-top-color",
|
||||
"border-right",
|
||||
"border-right-width",
|
||||
"border-right-style",
|
||||
"border-right-color",
|
||||
"border-bottom",
|
||||
"border-bottom-width",
|
||||
"border-bottom-style",
|
||||
"border-bottom-color",
|
||||
"border-left",
|
||||
"border-left-width",
|
||||
"border-left-style",
|
||||
"border-left-color",
|
||||
"-webkit-border-radius",
|
||||
"-moz-border-radius",
|
||||
"border-radius",
|
||||
"-webkit-border-top-left-radius",
|
||||
"-moz-border-radius-topleft",
|
||||
"border-top-left-radius",
|
||||
"-webkit-border-top-right-radius",
|
||||
"-moz-border-radius-topright",
|
||||
"border-top-right-radius",
|
||||
"-webkit-border-bottom-right-radius",
|
||||
"-moz-border-radius-bottomright",
|
||||
"border-bottom-right-radius",
|
||||
"-webkit-border-bottom-left-radius",
|
||||
"-moz-border-radius-bottomleft",
|
||||
"border-bottom-left-radius",
|
||||
"-webkit-border-image",
|
||||
"-moz-border-image",
|
||||
"-o-border-image",
|
||||
"border-image",
|
||||
"-webkit-border-image-source",
|
||||
"-moz-border-image-source",
|
||||
"-o-border-image-source",
|
||||
"border-image-source",
|
||||
"-webkit-border-image-slice",
|
||||
"-moz-border-image-slice",
|
||||
"-o-border-image-slice",
|
||||
"border-image-slice",
|
||||
"-webkit-border-image-width",
|
||||
"-moz-border-image-width",
|
||||
"-o-border-image-width",
|
||||
"border-image-width",
|
||||
"-webkit-border-image-outset",
|
||||
"-moz-border-image-outset",
|
||||
"-o-border-image-outset",
|
||||
"border-image-outset",
|
||||
"-webkit-border-image-repeat",
|
||||
"-moz-border-image-repeat",
|
||||
"-o-border-image-repeat",
|
||||
"border-image-repeat",
|
||||
"outline",
|
||||
"outline-width",
|
||||
"outline-style",
|
||||
"outline-color",
|
||||
"outline-offset",
|
||||
"background",
|
||||
"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader",
|
||||
"background-color",
|
||||
"background-image",
|
||||
"background-repeat",
|
||||
"background-attachment",
|
||||
"background-position",
|
||||
"background-position-x",
|
||||
"-ms-background-position-x",
|
||||
"background-position-y",
|
||||
"-ms-background-position-y",
|
||||
"-webkit-background-clip",
|
||||
"-moz-background-clip",
|
||||
"background-clip",
|
||||
"background-origin",
|
||||
"-webkit-background-size",
|
||||
"-moz-background-size",
|
||||
"-o-background-size",
|
||||
"background-size",
|
||||
"box-decoration-break",
|
||||
"-webkit-box-shadow",
|
||||
"-moz-box-shadow",
|
||||
"box-shadow",
|
||||
"filter:progid:DXImageTransform.Microsoft.gradient",
|
||||
"-ms-filter:\\'progid:DXImageTransform.Microsoft.gradient",
|
||||
"text-shadow"
|
||||
]
|
||||
]
|
||||
}
|
||||
13
BACK_BACK/node_modules/promise-queue/.editorconfig
generated
vendored
Executable file
13
BACK_BACK/node_modules/promise-queue/.editorconfig
generated
vendored
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
; editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[GNUmakefile]
|
||||
indent_style = tab
|
||||
37
BACK_BACK/node_modules/promise-queue/.jscs.json
generated
vendored
Executable file
37
BACK_BACK/node_modules/promise-queue/.jscs.json
generated
vendored
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"excludeFiles": [
|
||||
".git/**",
|
||||
"node_modules/**"
|
||||
],
|
||||
|
||||
"requireCurlyBraces": ["if", "else", "for", "while", "do"],
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return"],
|
||||
"requireRightStickedOperators": ["!"],
|
||||
"requireLeftStickedOperators": [","],
|
||||
|
||||
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
|
||||
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
|
||||
"disallowImplicitTypeConversion": ["string"],
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideObjectBrackets": true,
|
||||
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"safeContextKeyword": "self",
|
||||
|
||||
"validateJSDoc": {
|
||||
"checkParamNames": true,
|
||||
"requireParamTypes": true,
|
||||
"checkRedundantParams": true
|
||||
},
|
||||
|
||||
"requireSpacesInFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true,
|
||||
"beforeOpeningRoundBrace": true
|
||||
}
|
||||
}
|
||||
1
BACK_BACK/node_modules/promise-queue/.jshintignore
generated
vendored
Executable file
1
BACK_BACK/node_modules/promise-queue/.jshintignore
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
node_modules
|
||||
22
BACK_BACK/node_modules/promise-queue/.jshintrc
generated
vendored
Executable file
22
BACK_BACK/node_modules/promise-queue/.jshintrc
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"es5": false,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"node": true,
|
||||
"jquery": true,
|
||||
"strict": false,
|
||||
"browser": true,
|
||||
"indent": 4,
|
||||
"maxerr": 5,
|
||||
"maxdepth": 2,
|
||||
"maxstatements": 12,
|
||||
"maxcomplexity": 5
|
||||
}
|
||||
4
BACK_BACK/node_modules/promise-queue/.npmignore
generated
vendored
Executable file
4
BACK_BACK/node_modules/promise-queue/.npmignore
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
test/
|
||||
.DS_Store
|
||||
coverage.html
|
||||
html-report
|
||||
11
BACK_BACK/node_modules/promise-queue/.travis.yml
generated
vendored
Executable file
11
BACK_BACK/node_modules/promise-queue/.travis.yml
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- node_js: "0.8"
|
||||
|
||||
script: make travis
|
||||
1
BACK_BACK/node_modules/promise-queue/AUTHORS
generated
vendored
Executable file
1
BACK_BACK/node_modules/promise-queue/AUTHORS
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
Mikhail Davydov <i@azproduction.ru>
|
||||
9
BACK_BACK/node_modules/promise-queue/CHANGELOG.md
generated
vendored
Executable file
9
BACK_BACK/node_modules/promise-queue/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
Version 2.0.0:
|
||||
* It uses global `Promise` if possible.
|
||||
* `configure()` accepts Promise constructor according to the spec.
|
||||
|
||||
Version 1.0.1:
|
||||
* window.query -> window.Queue
|
||||
|
||||
Version 1.0.0:
|
||||
* Initial release.
|
||||
25
BACK_BACK/node_modules/promise-queue/CONTRIBUTION.md
generated
vendored
Executable file
25
BACK_BACK/node_modules/promise-queue/CONTRIBUTION.md
generated
vendored
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
# Contribution Guide
|
||||
|
||||
This document describes some points about contribution process for promise-queue package.
|
||||
|
||||
The maintainer of the project is Mikhail Davydov (i@azproduction.ru).
|
||||
|
||||
The project is being developed within community. Maintainer merges pull-requests, fixes critical bugs.
|
||||
|
||||
## Pull-requests
|
||||
|
||||
If you fixed or added something useful to the project, you can send pull-request.
|
||||
It will be reviewed by maintainer and accepted, or commented for rework, or declined.
|
||||
|
||||
## Bugs
|
||||
|
||||
If you found an error, mistype or any other flawback in the project, please report about it using github-issues.
|
||||
The more details you provide, the easier it can be reproduced and the faster can be fixed.
|
||||
Unfortunately, sometimes the bug can be only reproduced in your project or in your environment,
|
||||
so maintainers cannot reproduce it. In this case we believe you can fix the bug and send us the fix.
|
||||
|
||||
## Features
|
||||
|
||||
It you've got an idea about a new feature, it's most likely that you have do implement it on your own.
|
||||
If you cannot implement the feature, but it is very important, you can add a task in github-issues,
|
||||
but expect it be declined by the maintainer.
|
||||
22
BACK_BACK/node_modules/promise-queue/LICENSE
generated
vendored
Executable file
22
BACK_BACK/node_modules/promise-queue/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Mikhail Davydov and other contributors
|
||||
|
||||
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.
|
||||
42
BACK_BACK/node_modules/promise-queue/Makefile
generated
vendored
Executable file
42
BACK_BACK/node_modules/promise-queue/Makefile
generated
vendored
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
BIN = ./node_modules/.bin
|
||||
MOCHA = $(BIN)/mocha
|
||||
ISTANBUL = $(BIN)/istanbul
|
||||
JSHINT = $(BIN)/jshint
|
||||
JSCS = $(BIN)/jscs
|
||||
COVERALLS = $(BIN)/coveralls
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
$(MOCHA) -u bdd -R spec --recursive
|
||||
|
||||
.PHONY: validate
|
||||
validate: lint test
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf lib-cov
|
||||
-rm -rf html-report
|
||||
|
||||
.PHONY: lib-cov
|
||||
lib-cov: clean
|
||||
$(ISTANBUL) instrument --output lib-cov --no-compact --variable global.__coverage__ lib
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: lib-cov
|
||||
PROMISE_QUEUE_COVERAGE=1 $(MOCHA) --reporter mocha-istanbul
|
||||
@echo
|
||||
@echo Open html-report/index.html file in your browser
|
||||
|
||||
.PHONY: coveralls
|
||||
coveralls: lib-cov
|
||||
@PROMISE_QUEUE_COVERAGE=1 ISTANBUL_REPORTERS=lcovonly $(MOCHA) --reporter mocha-istanbul
|
||||
@cat lcov.info | $(COVERALLS)
|
||||
@rm -rf lib-cov lcov.info
|
||||
|
||||
.PHONY: travis
|
||||
travis: validate coveralls
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(JSHINT) .
|
||||
$(JSCS) .
|
||||
88
BACK_BACK/node_modules/promise-queue/README.md
generated
vendored
Executable file
88
BACK_BACK/node_modules/promise-queue/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
# promise-queue [](https://npmjs.org/package/promise-queue) [](https://travis-ci.org/azproduction/promise-queue) [](https://coveralls.io/r/azproduction/promise-queue) [](https://gemnasium.com/azproduction/promise-queue)
|
||||
|
||||
Promise-based queue
|
||||
|
||||
## Installation
|
||||
|
||||
`promise-queue` can be installed using `npm`:
|
||||
|
||||
```
|
||||
npm install promise-queue
|
||||
```
|
||||
|
||||
## Interface
|
||||
|
||||
- `new Queue(Number maxConcurrent, Number maxQueued): Queue`
|
||||
- `Queue#add(Function generator): Promise` - adds function argument that generates a promise to the queue
|
||||
- `Queue#getQueueLength(): Number` - returns current length of buffer(added but not started promise generators) `it <= maxQueued`
|
||||
- `Queue#getPendingLength(): Number` - returns number of pending(concurrently running) promises `it <= maxConcurrent`
|
||||
|
||||
## Example
|
||||
|
||||
### Configure queue
|
||||
|
||||
By default `Queue` tries to use global Promises, but you can specify your own promises.
|
||||
|
||||
```js
|
||||
Queue.configure(require('vow').Promise);
|
||||
```
|
||||
|
||||
Or use old-style promises approach:
|
||||
|
||||
```js
|
||||
Queue.configure(function (handler) {
|
||||
var dfd = $.Deferred();
|
||||
try {
|
||||
handler(dfd.resolve, dfd.reject, dfd.notify);
|
||||
} catch (e) {
|
||||
dfd.reject(e);
|
||||
}
|
||||
return dfd.promise();
|
||||
});
|
||||
```
|
||||
|
||||
### Queue one by one example
|
||||
|
||||
```js
|
||||
var maxConcurrent = 1;
|
||||
var maxQueue = Infinity;
|
||||
var queue = new Queue(maxConcurrent, maxQueue);
|
||||
|
||||
app.get('/version/:user/:repo', function (req, res, next) {
|
||||
queue.add(function () {
|
||||
// Assume that this action is a way too expensive
|
||||
// Call of this function will be delayed on second request
|
||||
return downloadTarballFromGithub(req.params);
|
||||
})
|
||||
.then(parseJson('package.json'))
|
||||
.then(function (package) {
|
||||
res.send(package.version);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
```
|
||||
|
||||
### Getting number of pending promises and queue(buffered promises) length
|
||||
|
||||
```js
|
||||
var maxConcurrent = 1;
|
||||
var maxQueue = 1;
|
||||
var queue = new Queue(maxConcurrent, maxQueue);
|
||||
|
||||
queue.add(function () {
|
||||
queue.getQueueLength() === 0;
|
||||
queue.getPendingLength() === 1;
|
||||
return somePromise();
|
||||
});
|
||||
|
||||
queue.add(function () {
|
||||
queue.getQueueLength() === 0;
|
||||
queue.getPendingLength() === 0;
|
||||
return somePromise();
|
||||
});
|
||||
|
||||
queue.getQueueLength() === 1;
|
||||
queue.getPendingLength() === 1;
|
||||
```
|
||||
|
||||
[Live example](http://jsfiddle.net/RVuEU/1/)
|
||||
3
BACK_BACK/node_modules/promise-queue/index.js
generated
vendored
Executable file
3
BACK_BACK/node_modules/promise-queue/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = process.env.PROMISE_QUEUE_COVERAGE ?
|
||||
require('./lib-cov') :
|
||||
require('./lib');
|
||||
0
BACK_BACK/node_modules/promise-queue/lib-cov/index.js
generated
vendored
Executable file
0
BACK_BACK/node_modules/promise-queue/lib-cov/index.js
generated
vendored
Executable file
182
BACK_BACK/node_modules/promise-queue/lib/index.js
generated
vendored
Executable file
182
BACK_BACK/node_modules/promise-queue/lib/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,182 @@
|
|||
/* global define, Promise */
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if (typeof module === 'object' && module.exports && typeof require === 'function') {
|
||||
// CommonJS
|
||||
module.exports = factory();
|
||||
} else if (typeof define === 'function' && typeof define.amd === 'object') {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
} else {
|
||||
// Browser globals
|
||||
root.Queue = factory();
|
||||
}
|
||||
})
|
||||
(this, function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @return {Object}
|
||||
*/
|
||||
var LocalPromise = typeof Promise !== 'undefined' ? Promise : function () {
|
||||
return {
|
||||
then: function () {
|
||||
throw new Error('Queue.configure() before use Queue');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var noop = function () {};
|
||||
|
||||
/**
|
||||
* @param {*} value
|
||||
* @returns {LocalPromise}
|
||||
*/
|
||||
var resolveWith = function (value) {
|
||||
if (value && typeof value.then === 'function') {
|
||||
return value;
|
||||
}
|
||||
|
||||
return new LocalPromise(function (resolve) {
|
||||
resolve(value);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* It limits concurrently executed promises
|
||||
*
|
||||
* @param {Number} [maxPendingPromises=Infinity] max number of concurrently executed promises
|
||||
* @param {Number} [maxQueuedPromises=Infinity] max number of queued promises
|
||||
* @constructor
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var queue = new Queue(1);
|
||||
*
|
||||
* queue.add(function () {
|
||||
* // resolve of this promise will resume next request
|
||||
* return downloadTarballFromGithub(url, file);
|
||||
* })
|
||||
* .then(function (file) {
|
||||
* doStuffWith(file);
|
||||
* });
|
||||
*
|
||||
* queue.add(function () {
|
||||
* return downloadTarballFromGithub(url, file);
|
||||
* })
|
||||
* // This request will be paused
|
||||
* .then(function (file) {
|
||||
* doStuffWith(file);
|
||||
* });
|
||||
*/
|
||||
function Queue(maxPendingPromises, maxQueuedPromises, options) {
|
||||
this.options = options = options || {};
|
||||
this.pendingPromises = 0;
|
||||
this.maxPendingPromises = typeof maxPendingPromises !== 'undefined' ? maxPendingPromises : Infinity;
|
||||
this.maxQueuedPromises = typeof maxQueuedPromises !== 'undefined' ? maxQueuedPromises : Infinity;
|
||||
this.queue = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines promise promiseFactory
|
||||
* @param {Function} GlobalPromise
|
||||
*/
|
||||
Queue.configure = function (GlobalPromise) {
|
||||
LocalPromise = GlobalPromise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} promiseGenerator
|
||||
* @return {LocalPromise}
|
||||
*/
|
||||
Queue.prototype.add = function (promiseGenerator) {
|
||||
var self = this;
|
||||
return new LocalPromise(function (resolve, reject, notify) {
|
||||
// Do not queue to much promises
|
||||
if (self.queue.length >= self.maxQueuedPromises) {
|
||||
reject(new Error('Queue limit reached'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to queue
|
||||
self.queue.push({
|
||||
promiseGenerator: promiseGenerator,
|
||||
resolve: resolve,
|
||||
reject: reject,
|
||||
notify: notify || noop
|
||||
});
|
||||
|
||||
self._dequeue();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Number of simultaneously running promises (which are resolving)
|
||||
*
|
||||
* @return {number}
|
||||
*/
|
||||
Queue.prototype.getPendingLength = function () {
|
||||
return this.pendingPromises;
|
||||
};
|
||||
|
||||
/**
|
||||
* Number of queued promises (which are waiting)
|
||||
*
|
||||
* @return {number}
|
||||
*/
|
||||
Queue.prototype.getQueueLength = function () {
|
||||
return this.queue.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean} true if first item removed from queue
|
||||
* @private
|
||||
*/
|
||||
Queue.prototype._dequeue = function () {
|
||||
var self = this;
|
||||
if (this.pendingPromises >= this.maxPendingPromises) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from queue
|
||||
var item = this.queue.shift();
|
||||
if (!item) {
|
||||
if (this.options.onEmpty) {
|
||||
this.options.onEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
this.pendingPromises++;
|
||||
|
||||
resolveWith(item.promiseGenerator())
|
||||
// Forward all stuff
|
||||
.then(function (value) {
|
||||
// It is not pending now
|
||||
self.pendingPromises--;
|
||||
// It should pass values
|
||||
item.resolve(value);
|
||||
self._dequeue();
|
||||
}, function (err) {
|
||||
// It is not pending now
|
||||
self.pendingPromises--;
|
||||
// It should not mask errors
|
||||
item.reject(err);
|
||||
self._dequeue();
|
||||
}, function (message) {
|
||||
// It should pass notifications
|
||||
item.notify(message);
|
||||
});
|
||||
} catch (err) {
|
||||
self.pendingPromises--;
|
||||
item.reject(err);
|
||||
self._dequeue();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return Queue;
|
||||
});
|
||||
44
BACK_BACK/node_modules/promise-queue/package.json
generated
vendored
Executable file
44
BACK_BACK/node_modules/promise-queue/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"author": "Mikhail Davydov <i@azproduction.ru>",
|
||||
"description": "Promise-based queue",
|
||||
"name": "promise-queue",
|
||||
"version": "2.2.5",
|
||||
"contributors": [
|
||||
"Mikhail Davydov <i@azproduction.ru>"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/azproduction/promise-queue.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint": "2.1.3",
|
||||
"mocha": "1.11.0",
|
||||
"jscs": "1.0.0",
|
||||
"istanbul": "0.1.39",
|
||||
"chai": "3.5.0",
|
||||
"sinon": "1.17.7",
|
||||
"vow": "0.4.1",
|
||||
"sinon-chai": "2.8.0",
|
||||
"mocha-istanbul": "0.3.0",
|
||||
"coveralls": "2.11.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make validate",
|
||||
"lint": "make lint",
|
||||
"coverage": "make coverage",
|
||||
"clean": "make clean"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/azproduction/promise-queue/issues"
|
||||
},
|
||||
"homepage": "https://github.com/azproduction/promise-queue#readme",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {},
|
||||
"license": "MIT"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue