mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
Moving to node_modules folder to make easier to upgrade
trying to move from Bootstrap 3 to Bootstrap 5
This commit is contained in:
parent
047e363a16
commit
d4d042e041
8460 changed files with 1355889 additions and 547977 deletions
12
node_modules/promise-polyfill/.editorconfig
generated
vendored
Normal file
12
node_modules/promise-polyfill/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = false
|
26
node_modules/promise-polyfill/.eslintrc.js
generated
vendored
Normal file
26
node_modules/promise-polyfill/.eslintrc.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
};
|
2
node_modules/promise-polyfill/.npmignore
generated
vendored
Normal file
2
node_modules/promise-polyfill/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.idea
|
||||
node_modules
|
7
node_modules/promise-polyfill/.travis.yml
generated
vendored
Normal file
7
node_modules/promise-polyfill/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.12
|
||||
before_install:
|
||||
- export CHROME_BIN=chromium-browser
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
98
node_modules/promise-polyfill/CHANGELOG.md
generated
vendored
Normal file
98
node_modules/promise-polyfill/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
# Changelog
|
||||
## 6.1.0
|
||||
- Bug fix for non-array values in `Promise.all()`
|
||||
- Small optimization checking for making sure `Promise` is called with `new`
|
||||
|
||||
|
||||
## 6.0.0 Deprecated `Promise._setImmediateFn` and `Promise._setUnhandledRejectionFn`
|
||||
This allows subclassing Promise without rewriting functions
|
||||
- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>` instead.
|
||||
- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
|
||||
These functions will be removed in the next major version.
|
||||
|
||||
### 5.2.1 setTimeout to 0
|
||||
Fixed bug where setTimeout was set to 1 instead of 0 for async execution
|
||||
|
||||
### 5.2.0 Subclassing
|
||||
Allowed Subclassing. [#27](https://github.com/taylorhakes/promise-polyfill/pull/27)
|
||||
|
||||
### 5.1.0 Fixed reliance on setTimeout
|
||||
Changed possibly unhanded warnings to use asap function instead of setTimeout
|
||||
|
||||
## 5.0.0 Removed multiple params from Promise.all
|
||||
Removed non standard functionality of passing multiple params to Promise.all. You must pass an array now. You must change this code
|
||||
```js
|
||||
Promise.all(prom1, prom2, prom3);
|
||||
```
|
||||
to this
|
||||
```js
|
||||
Promise.all([prom1, prom2, prom3]);
|
||||
```
|
||||
|
||||
### 4.0.4 IE8 console.warn fix
|
||||
IE8 does not have console, unless you open the developer tools. This fix checks to makes sure console.warn is defined before calling it.
|
||||
|
||||
### 4.0.3 Fix case in bower.json
|
||||
bower.json had Promise.js instead of promise.js
|
||||
|
||||
### 4.0.2 promise.js case fix in package.json
|
||||
Fixed promise.js in package.json. It was accidently published as Promise.js
|
||||
|
||||
## 4.0.1 Unhandled Rejections and Other Fixes
|
||||
- Added unhandled rejection warnings to the console
|
||||
- Removed Grunt, jasmine and other unused code
|
||||
- Renamed Promise.js to lowercase promise.js in multiple places
|
||||
|
||||
### 3.0.1 Fixed shadowing issue on setTimeout
|
||||
New version fixing this major bug https://github.com/taylorhakes/promise-polyfill/pull/17
|
||||
|
||||
## 3.0.0 Updated setTimeout to not be affected by test mocks
|
||||
This is considered a breaking change because people may have been using this functionality. If you would like to keep version 2 functionality, set Promise._setImmediateFn on `promise-polyfill` like the code below.
|
||||
|
||||
```js
|
||||
var Promise = require('promise-polyfill');
|
||||
Promise._setImmedateFn(function(fn) {
|
||||
setTimeout(fn, 1);
|
||||
});
|
||||
```
|
||||
|
||||
### 2.1.0 Promise._setImmedateFn
|
||||
Removed dead code Promise.immedateFn and added Promise._setImmediateFn(fn);
|
||||
|
||||
### 2.0.2 Simplified Global detection
|
||||
Simplified attaching to global object
|
||||
|
||||
### 2.0.1 Webworker bugfixes
|
||||
Fixed Webworkers missing window object
|
||||
|
||||
## 2.0.0
|
||||
**Changed the following line**
|
||||
```
|
||||
module.exports = root.Promise ? root.Promise : Promise;
|
||||
```
|
||||
to
|
||||
```
|
||||
module.exports = Promise;
|
||||
```
|
||||
|
||||
This means the library will not use built-in Promise by default. This allows for more consistency.
|
||||
|
||||
You can easily add the functionality back.
|
||||
```
|
||||
var Promise = window.Promise || require('promise-polyfill');
|
||||
```
|
||||
|
||||
**Added Promise.immediateFn to allow changing the setImmedate function**
|
||||
```
|
||||
Promise.immediateFn = window.setAsap;
|
||||
```
|
||||
|
||||
### 1.1.4 Updated Promise to use correct global object in Browser and Node
|
||||
|
||||
### 1.1.3 Fixed browserify issue with `this`
|
||||
|
||||
### 1.1.2 Updated Promise.resolve to resolve with original Promise
|
||||
|
||||
### 1.1.0 Performance Improvements for Modern Browsers
|
||||
|
||||
## 1.0.1 Update README.md
|
20
node_modules/promise-polyfill/LICENSE
generated
vendored
Normal file
20
node_modules/promise-polyfill/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2014 Taylor Hakes
|
||||
Copyright (c) 2014 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.
|
96
node_modules/promise-polyfill/README.md
generated
vendored
Normal file
96
node_modules/promise-polyfill/README.md
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
# Promise Polyfill
|
||||
[![travis][travis-image]][travis-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/taylorhakes/promise-polyfill.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/taylorhakes/promise-polyfill
|
||||
|
||||
|
||||
Lightweight ES6 Promise polyfill for the browser and node. Adheres closely to the spec. It is a perfect polyfill IE, Firefox or any other browser that does not support native promises.
|
||||
|
||||
For API information about Promises, please check out this article [HTML5Rocks article](http://www.html5rocks.com/en/tutorials/es6/promises/).
|
||||
|
||||
It is extremely lightweight. ***< 1kb Gzipped***
|
||||
|
||||
## Browser Support
|
||||
IE8+, Chrome, Firefox, IOS 4+, Safari 5+, Opera
|
||||
|
||||
### NPM Use
|
||||
```
|
||||
npm install promise-polyfill --save-exact
|
||||
```
|
||||
### Bower Use
|
||||
```
|
||||
bower install promise-polyfill
|
||||
```
|
||||
### CDN Use
|
||||
```
|
||||
<script href="https://cdn.jsdelivr.net/npm/promise-polyfill@6/promise.min.js"></script>
|
||||
```
|
||||
|
||||
## Downloads
|
||||
|
||||
- [Promise](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.js)
|
||||
- [Promise-min](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.min.js)
|
||||
|
||||
## Simple use
|
||||
```js
|
||||
import Promise from 'promise-polyfill';
|
||||
|
||||
// To add to window
|
||||
if (!window.Promise) {
|
||||
window.Promise = Promise;
|
||||
}
|
||||
```
|
||||
|
||||
then you can use like normal Promises
|
||||
```js
|
||||
var prom = new Promise(function(resolve, reject) {
|
||||
// do a thing, possibly async, then…
|
||||
|
||||
if (/* everything turned out fine */) {
|
||||
resolve("Stuff worked!");
|
||||
} else {
|
||||
reject(new Error("It broke"));
|
||||
}
|
||||
});
|
||||
|
||||
prom.then(function(result) {
|
||||
// Do something when async done
|
||||
});
|
||||
```
|
||||
|
||||
## Deprecations
|
||||
- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>;` instead.
|
||||
- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
|
||||
These functions will be removed in the next major version.
|
||||
|
||||
## Performance
|
||||
By default promise-polyfill uses `setImmediate`, but falls back to `setTimeout` for executing asynchronously. If a browser does not support `setImmediate` (IE/Edge are the only browsers with setImmediate), you may see performance issues.
|
||||
Use a `setImmediate` polyfill to fix this issue. [setAsap](https://github.com/taylorhakes/setAsap) or [setImmediate](https://github.com/YuzuJS/setImmediate) work well.
|
||||
|
||||
If you polyfill `window.setImmediate` or use `Promise._immediateFn = yourImmediateFn` it will be used instead of `window.setTimeout`
|
||||
```
|
||||
npm install setasap --save
|
||||
```
|
||||
```js
|
||||
var Promise = require('promise-polyfill');
|
||||
var setAsap = require('setasap');
|
||||
Promise._immediateFn = setAsap;
|
||||
```
|
||||
|
||||
## Unhandled Rejections
|
||||
promise-polyfill will warn you about possibly unhandled rejections. It will show a console warning if a Promise is rejected, but no `.catch` is used. You can turn off this behavior by setting `Promise._setUnhandledRejectionFn(<rejectError>)`.
|
||||
If you would like to disable unhandled rejections. Use a noop like below.
|
||||
```js
|
||||
Promise._unhandledRejectionFn = function(rejectError) {};
|
||||
```
|
||||
|
||||
|
||||
## Testing
|
||||
```
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
## License
|
||||
MIT
|
28
node_modules/promise-polyfill/bower.json
generated
vendored
Normal file
28
node_modules/promise-polyfill/bower.json
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "promise-polyfill",
|
||||
"version": "6.1.0",
|
||||
"homepage": "https://github.com/taylorhakes/promise-polyfill",
|
||||
"authors": [
|
||||
"Taylor Hakes"
|
||||
],
|
||||
"description": "Lightweight promise polyfill for the browser and node. A+ Compliant.",
|
||||
"main": "promise.js",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"es6",
|
||||
"polyfill",
|
||||
"html5"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
75
node_modules/promise-polyfill/karma.conf.js
generated
vendored
Normal file
75
node_modules/promise-polyfill/karma.conf.js
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Karma configuration
|
||||
// Generated on Tue Jan 12 2016 07:56:12 GMT-0500 (EST)
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha', 'browserify'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'test/promise.js'
|
||||
],
|
||||
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [],
|
||||
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'test/promise.js': ['browserify']
|
||||
},
|
||||
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['progress'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['Chrome'],
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity,
|
||||
|
||||
plugins: [
|
||||
'karma-browserify',
|
||||
'karma-mocha',
|
||||
'karma-chrome-launcher'
|
||||
]
|
||||
})
|
||||
}
|
65
node_modules/promise-polyfill/package.json
generated
vendored
Normal file
65
node_modules/promise-polyfill/package.json
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"_from": "promise-polyfill@^6.0.2",
|
||||
"_id": "promise-polyfill@6.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=",
|
||||
"_location": "/promise-polyfill",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "promise-polyfill@^6.0.2",
|
||||
"name": "promise-polyfill",
|
||||
"escapedName": "promise-polyfill",
|
||||
"rawSpec": "^6.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^6.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/sweetalert"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.1.0.tgz",
|
||||
"_shasum": "dfa96943ea9c121fca4de9b5868cb39d3472e057",
|
||||
"_spec": "promise-polyfill@^6.0.2",
|
||||
"_where": "G:\\GDrive\\htdocs\\YouPHPTube\\node_modules\\sweetalert",
|
||||
"author": {
|
||||
"name": "Taylor Hakes"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/taylorhakes/promise-polyfill/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Lightweight promise polyfill. A+ compliant",
|
||||
"devDependencies": {
|
||||
"eslint": "^2.4.0",
|
||||
"karma": "^0.13.19",
|
||||
"karma-browserify": "^4.4.2",
|
||||
"karma-chrome-launcher": "^0.2.2",
|
||||
"karma-mocha": "^0.2.1",
|
||||
"mocha": "^2.3.4",
|
||||
"promises-aplus-tests": "*",
|
||||
"sinon": "^1.17.2",
|
||||
"uglify-js": "^2.6.2"
|
||||
},
|
||||
"homepage": "https://github.com/taylorhakes/promise-polyfill",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"promise-polyfill",
|
||||
"ES6",
|
||||
"promises-aplus"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "promise.js",
|
||||
"name": "promise-polyfill",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://taylorhakes@github.com/taylorhakes/promise-polyfill.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "uglifyjs --compress --support-ie8 --mangle -o promise.min.js -- promise.js ",
|
||||
"test": "eslint promise.js && mocha && karma start --single-run"
|
||||
},
|
||||
"version": "6.1.0"
|
||||
}
|
233
node_modules/promise-polyfill/promise.js
generated
vendored
Normal file
233
node_modules/promise-polyfill/promise.js
generated
vendored
Normal file
|
@ -0,0 +1,233 @@
|
|||
(function (root) {
|
||||
|
||||
// Store setTimeout reference so promise-polyfill will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function () {
|
||||
fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function Promise(fn) {
|
||||
if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new');
|
||||
if (typeof fn !== 'function') throw new TypeError('not a function');
|
||||
this._state = 0;
|
||||
this._handled = false;
|
||||
this._value = undefined;
|
||||
this._deferreds = [];
|
||||
|
||||
doResolve(fn, this);
|
||||
}
|
||||
|
||||
function handle(self, deferred) {
|
||||
while (self._state === 3) {
|
||||
self = self._value;
|
||||
}
|
||||
if (self._state === 0) {
|
||||
self._deferreds.push(deferred);
|
||||
return;
|
||||
}
|
||||
self._handled = true;
|
||||
Promise._immediateFn(function () {
|
||||
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
||||
if (cb === null) {
|
||||
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
||||
return;
|
||||
}
|
||||
var ret;
|
||||
try {
|
||||
ret = cb(self._value);
|
||||
} catch (e) {
|
||||
reject(deferred.promise, e);
|
||||
return;
|
||||
}
|
||||
resolve(deferred.promise, ret);
|
||||
});
|
||||
}
|
||||
|
||||
function resolve(self, newValue) {
|
||||
try {
|
||||
// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
||||
if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.');
|
||||
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
||||
var then = newValue.then;
|
||||
if (newValue instanceof Promise) {
|
||||
self._state = 3;
|
||||
self._value = newValue;
|
||||
finale(self);
|
||||
return;
|
||||
} else if (typeof then === 'function') {
|
||||
doResolve(bind(then, newValue), self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
self._state = 1;
|
||||
self._value = newValue;
|
||||
finale(self);
|
||||
} catch (e) {
|
||||
reject(self, e);
|
||||
}
|
||||
}
|
||||
|
||||
function reject(self, newValue) {
|
||||
self._state = 2;
|
||||
self._value = newValue;
|
||||
finale(self);
|
||||
}
|
||||
|
||||
function finale(self) {
|
||||
if (self._state === 2 && self._deferreds.length === 0) {
|
||||
Promise._immediateFn(function() {
|
||||
if (!self._handled) {
|
||||
Promise._unhandledRejectionFn(self._value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0, len = self._deferreds.length; i < len; i++) {
|
||||
handle(self, self._deferreds[i]);
|
||||
}
|
||||
self._deferreds = null;
|
||||
}
|
||||
|
||||
function Handler(onFulfilled, onRejected, promise) {
|
||||
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
||||
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
||||
this.promise = promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a potentially misbehaving resolver function and make sure
|
||||
* onFulfilled and onRejected are only called once.
|
||||
*
|
||||
* Makes no guarantees about asynchrony.
|
||||
*/
|
||||
function doResolve(fn, self) {
|
||||
var done = false;
|
||||
try {
|
||||
fn(function (value) {
|
||||
if (done) return;
|
||||
done = true;
|
||||
resolve(self, value);
|
||||
}, function (reason) {
|
||||
if (done) return;
|
||||
done = true;
|
||||
reject(self, reason);
|
||||
});
|
||||
} catch (ex) {
|
||||
if (done) return;
|
||||
done = true;
|
||||
reject(self, ex);
|
||||
}
|
||||
}
|
||||
|
||||
Promise.prototype['catch'] = function (onRejected) {
|
||||
return this.then(null, onRejected);
|
||||
};
|
||||
|
||||
Promise.prototype.then = function (onFulfilled, onRejected) {
|
||||
var prom = new (this.constructor)(noop);
|
||||
|
||||
handle(this, new Handler(onFulfilled, onRejected, prom));
|
||||
return prom;
|
||||
};
|
||||
|
||||
Promise.all = function (arr) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!arr || typeof arr.length === 'undefined') throw new TypeError('Promise.all accepts an array');
|
||||
var args = Array.prototype.slice.call(arr);
|
||||
if (args.length === 0) return resolve([]);
|
||||
var remaining = args.length;
|
||||
|
||||
function res(i, val) {
|
||||
try {
|
||||
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
||||
var then = val.then;
|
||||
if (typeof then === 'function') {
|
||||
then.call(val, function (val) {
|
||||
res(i, val);
|
||||
}, reject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
args[i] = val;
|
||||
if (--remaining === 0) {
|
||||
resolve(args);
|
||||
}
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
res(i, args[i]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Promise.resolve = function (value) {
|
||||
if (value && typeof value === 'object' && value.constructor === Promise) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
resolve(value);
|
||||
});
|
||||
};
|
||||
|
||||
Promise.reject = function (value) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
reject(value);
|
||||
});
|
||||
};
|
||||
|
||||
Promise.race = function (values) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
for (var i = 0, len = values.length; i < len; i++) {
|
||||
values[i].then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) ||
|
||||
function (fn) {
|
||||
setTimeoutFunc(fn, 0);
|
||||
};
|
||||
|
||||
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
||||
if (typeof console !== 'undefined' && console) {
|
||||
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the immediate function to execute callbacks
|
||||
* @param fn {function} Function to execute
|
||||
* @deprecated
|
||||
*/
|
||||
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
||||
Promise._immediateFn = fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the function to execute on unhandled rejection
|
||||
* @param {function} fn Function to execute on unhandled rejection
|
||||
* @deprecated
|
||||
*/
|
||||
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
||||
Promise._unhandledRejectionFn = fn;
|
||||
};
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = Promise;
|
||||
} else if (!root.Promise) {
|
||||
root.Promise = Promise;
|
||||
}
|
||||
|
||||
})(this);
|
1
node_modules/promise-polyfill/promise.min.js
generated
vendored
Normal file
1
node_modules/promise-polyfill/promise.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],a(e,this)}function i(e,n){for(;3===e._state;)e=e._value;if(0===e._state)return void e._deferreds.push(n);e._handled=!0,o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:f)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void f(n.promise,i)}r(n.promise,o)})}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof i)return void a(t(i,n),e)}e._state=1,e._value=n,u(e)}catch(r){f(e,r)}}function f(e,n){e._state=2,e._value=n,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function a(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var s=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){return new o(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}i[e]=f,0==--r&&n(i)}catch(c){t(c)}}if(!e||"undefined"==typeof e.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(e);if(0===i.length)return n([]);for(var r=i.length,f=0;f<i.length;f++)o(f,i[f])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){s(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this);
|
14
node_modules/promise-polyfill/test/adapter.js
generated
vendored
Normal file
14
node_modules/promise-polyfill/test/adapter.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
var Promise = require('../promise');
|
||||
module.exports = {
|
||||
resolved: Promise.resolve,
|
||||
rejected: Promise.rejected,
|
||||
deferred: function() {
|
||||
var obj = {};
|
||||
var prom = new Promise(function(resolve, reject) {
|
||||
obj.resolve = resolve;
|
||||
obj.reject = reject;
|
||||
});
|
||||
obj.promise = prom;
|
||||
return obj;
|
||||
}
|
||||
};
|
248
node_modules/promise-polyfill/test/promise.js
generated
vendored
Normal file
248
node_modules/promise-polyfill/test/promise.js
generated
vendored
Normal file
|
@ -0,0 +1,248 @@
|
|||
var Promise = require('../promise');
|
||||
var sinon = require('sinon');
|
||||
var assert = require('assert');
|
||||
var adapter = require('./adapter');
|
||||
describe("Promises/A+ Tests", function () {
|
||||
require("promises-aplus-tests").mocha(adapter);
|
||||
});
|
||||
describe('Promise', function () {
|
||||
describe('Promise._setImmediateFn', function () {
|
||||
afterEach(function() {
|
||||
Promise._setImmediateFn((typeof setImmediate === 'function' && function (fn) {
|
||||
setImmediate(fn);
|
||||
}) ||
|
||||
function (fn) {
|
||||
setTimeout(fn, 1);
|
||||
});
|
||||
});
|
||||
it('changes immediate fn', function () {
|
||||
var spy = sinon.spy();
|
||||
|
||||
function immediateFn(fn) {
|
||||
spy();
|
||||
fn();
|
||||
}
|
||||
Promise._setImmediateFn(immediateFn);
|
||||
var done = false;
|
||||
new Promise(function (resolve) {
|
||||
resolve();
|
||||
}).then(function () {
|
||||
done = true;
|
||||
});
|
||||
assert(spy.calledOnce);
|
||||
assert(done);
|
||||
});
|
||||
it('changes immediate fn multiple', function () {
|
||||
var spy1 = sinon.spy();
|
||||
|
||||
function immediateFn1(fn) {
|
||||
spy1();
|
||||
fn();
|
||||
}
|
||||
|
||||
var spy2 = sinon.spy();
|
||||
|
||||
function immediateFn2(fn) {
|
||||
spy2();
|
||||
fn();
|
||||
}
|
||||
|
||||
Promise._setImmediateFn(immediateFn1);
|
||||
var done = false;
|
||||
new Promise(function (resolve) {
|
||||
resolve();
|
||||
}).then(function () {
|
||||
});
|
||||
Promise._setImmediateFn(immediateFn2);
|
||||
new Promise(function (resolve) {
|
||||
resolve();
|
||||
}).then(function () {
|
||||
done = true;
|
||||
});
|
||||
assert(spy2.called);
|
||||
assert(spy1.calledOnce);
|
||||
assert(done);
|
||||
});
|
||||
});
|
||||
describe('Promise._onUnhandledRejection', function () {
|
||||
var stub, sandbox;
|
||||
beforeEach(function() {
|
||||
sandbox = sinon.sandbox.create();
|
||||
stub = sandbox.stub(console, 'warn');
|
||||
});
|
||||
afterEach(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
it('no error on resolve', function (done) {
|
||||
Promise.resolve(true).then(function(result) {
|
||||
return result;
|
||||
}).then(function(result) {
|
||||
return result;
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
assert(!stub.called);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('error single Promise', function (done) {
|
||||
new Promise(function(resolve, reject) {
|
||||
abc.abc = 1;
|
||||
});
|
||||
setTimeout(function() {
|
||||
assert(stub.calledOnce);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('multi promise error', function (done) {
|
||||
new Promise(function(resolve, reject) {
|
||||
abc.abc = 1;
|
||||
}).then(function(result) {
|
||||
return result;
|
||||
});
|
||||
setTimeout(function() {
|
||||
assert(stub.calledOnce);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('promise catch no error', function (done) {
|
||||
new Promise(function(resolve, reject) {
|
||||
abc.abc = 1;
|
||||
}).catch(function(result) {
|
||||
return result;
|
||||
});
|
||||
setTimeout(function() {
|
||||
assert(!stub.called);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('promise catch no error', function (done) {
|
||||
new Promise(function(resolve, reject) {
|
||||
abc.abc = 1;
|
||||
}).then(function(result) {
|
||||
return result;
|
||||
}).catch(function(result) {
|
||||
return result;
|
||||
});
|
||||
setTimeout(function() {
|
||||
assert(!stub.called);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('promise reject error', function (done) {
|
||||
Promise.reject('hello');
|
||||
setTimeout(function() {
|
||||
assert(stub.calledOnce);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('promise reject error late', function (done) {
|
||||
var prom = Promise.reject('hello');
|
||||
prom.catch(function() {
|
||||
|
||||
});
|
||||
setTimeout(function() {
|
||||
assert(!stub.called);
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
it('promise reject error late', function (done) {
|
||||
Promise.reject('hello');
|
||||
setTimeout(function() {
|
||||
assert.equal(stub.args[0][1], 'hello');
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
describe('Promise.prototype.then', function() {
|
||||
var spy,
|
||||
SubClass;
|
||||
beforeEach(function() {
|
||||
spy = sinon.spy();
|
||||
SubClass = function() {
|
||||
spy();
|
||||
Promise.apply(this, arguments);
|
||||
};
|
||||
|
||||
function __() { this.constructor = SubClass; }
|
||||
__.prototype = Promise.prototype;
|
||||
SubClass.prototype = new __();
|
||||
|
||||
SubClass.prototype.then = function() {
|
||||
return Promise.prototype.then.apply(this, arguments);
|
||||
};
|
||||
});
|
||||
it('subclassed Promise resolves to subclass', function() {
|
||||
var prom = new SubClass(function(resolve) {
|
||||
resolve();
|
||||
}).then(function() {}, function() {});
|
||||
assert(spy.calledTwice);
|
||||
assert(prom instanceof SubClass);
|
||||
});
|
||||
it('subclassed Promise rejects to subclass', function() {
|
||||
var prom = new SubClass(function(_, reject) {
|
||||
reject();
|
||||
}).then(function() {}, function() {});
|
||||
assert(spy.calledTwice);
|
||||
assert(prom instanceof SubClass);
|
||||
});
|
||||
});
|
||||
describe('Promise.all', function() {
|
||||
it('throws on implicit undefined', function () {
|
||||
return Promise.all().then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on explicit undefined', function () {
|
||||
return Promise.all(undefined).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on null', function () {
|
||||
return Promise.all(null).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on 0', function () {
|
||||
return Promise.all(0).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on false', function () {
|
||||
return Promise.all(false).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on a number', function () {
|
||||
return Promise.all().then(function () {
|
||||
assert.fail(20);
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on a boolean', function () {
|
||||
return Promise.all(true).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
it('throws on an object', function () {
|
||||
return Promise.all({ test: 'object' }).then(function () {
|
||||
assert.fail();
|
||||
}, function (error) {
|
||||
assert.ok(error instanceof Error);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue