mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
168
node_modules/promise-polyfill/CHANGELOG.md
generated
vendored
Normal file
168
node_modules/promise-polyfill/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
# Changelog
|
||||
|
||||
### 8.1.0
|
||||
|
||||
* Added Closure compiler type definitions
|
||||
|
||||
### 8.0.0
|
||||
|
||||
* Polyfill default promise with `finally` if it doesn't exist if you use polyfill.js
|
||||
* If using `require` with webpack 2+, you now need to do
|
||||
|
||||
```js
|
||||
var Promise = require('promise-polyfill').default;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```js
|
||||
var Promise = require('promise-polyfill');
|
||||
```
|
||||
|
||||
* Removed files /dist/promise.js and /dist/promise.min.js. These files were not used unless you downloaded them directly from the repo. They were not used by ES6 modules, CommonJS or polyfill.js
|
||||
The file lead to issues because they overrode the global Promise by default.
|
||||
|
||||
### 7.1.2
|
||||
|
||||
* Fixed bug in Node JS Promise polyfill
|
||||
|
||||
### 7.1.0
|
||||
|
||||
* Added Promise.prototype.finally
|
||||
|
||||
### 7.0.2
|
||||
|
||||
* Added IE8 compatability back to minify
|
||||
|
||||
### 7.0.1
|
||||
|
||||
* Fixed a bug in 'catch' keyword in IE8
|
||||
* Fixed import error when using `require`
|
||||
|
||||
## 7.0.0
|
||||
|
||||
* Updated code to ES6 module definitions (thanks Andarist)
|
||||
* Added polyfill.js file
|
||||
* move compiled files to dist folder
|
||||
|
||||
## 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.
|
135
node_modules/promise-polyfill/README.md
generated
vendored
Normal file
135
node_modules/promise-polyfill/README.md
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
# 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 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 Polyfill Use
|
||||
|
||||
This will set a global Promise object if the browser doesn't already have `window.Promise`.
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
|
||||
```
|
||||
|
||||
## Downloads
|
||||
|
||||
* [Promise](https://raw.github.com/taylorhakes/promise-polyfill/master/dist/polyfill.js)
|
||||
* [Promise-min](https://raw.github.com/taylorhakes/promise-polyfill/master/dist/polyfill.min.js)
|
||||
|
||||
## Simple use
|
||||
|
||||
If you would like to add a global Promise object (Node or Browser) if native Promise doesn't exist (polyfill Promise). Use the method below. This is useful it you are building a website and want to support older browsers.
|
||||
Javascript library authors should _NOT_ use this method.
|
||||
|
||||
```js
|
||||
import 'promise-polyfill/src/polyfill';
|
||||
```
|
||||
|
||||
If you would like to not affect the global environment (sometimes known as a [ponyfill](https://github.com/sindresorhus/ponyfill), you can import the base module. This is nice for library authors or people working in environment where you don't want
|
||||
to affect the global environment.
|
||||
|
||||
```js
|
||||
import Promise from 'promise-polyfill';
|
||||
```
|
||||
|
||||
If using `require` with Webpack 2+ (rare), you need to specify the default import
|
||||
|
||||
```js
|
||||
var Promise = require('promise-polyfill').default;
|
||||
```
|
||||
|
||||
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
|
||||
});
|
||||
```
|
||||
|
||||
## 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
|
||||
import Promise from 'promise-polyfill/src/polyfill';
|
||||
import setAsap from '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
|
||||
change this behavior by doing.
|
||||
|
||||
-**NOTE: This only works on promise-polyfill Promises. Native Promises do not support this function**
|
||||
|
||||
```js
|
||||
Promise._unhandledRejectionFn = <your reject error handler>;
|
||||
```
|
||||
|
||||
If you would like to disable unhandled rejection messages. Use a noop like
|
||||
below.
|
||||
|
||||
```js
|
||||
Promise._unhandledRejectionFn = function(rejectError) {};
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
301
node_modules/promise-polyfill/dist/polyfill.js
generated
vendored
Normal file
301
node_modules/promise-polyfill/dist/polyfill.js
generated
vendored
Normal file
@ -0,0 +1,301 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* @this {Promise}
|
||||
*/
|
||||
function finallyConstructor(callback) {
|
||||
var constructor = this.constructor;
|
||||
return this.then(
|
||||
function(value) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
return value;
|
||||
});
|
||||
},
|
||||
function(reason) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
// @ts-ignore
|
||||
return constructor.reject(reason);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Store setTimeout reference so promise-polyfill will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function isArray(x) {
|
||||
return Boolean(x && typeof x.length !== 'undefined');
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function() {
|
||||
fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Function} fn
|
||||
*/
|
||||
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');
|
||||
/** @type {!number} */
|
||||
this._state = 0;
|
||||
/** @type {!boolean} */
|
||||
this._handled = false;
|
||||
/** @type {Promise|undefined} */
|
||||
this._value = undefined;
|
||||
/** @type {!Array<!Function>} */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
// @ts-ignore
|
||||
var prom = new this.constructor(noop);
|
||||
|
||||
handle(this, new Handler(onFulfilled, onRejected, prom));
|
||||
return prom;
|
||||
};
|
||||
|
||||
Promise.prototype['finally'] = finallyConstructor;
|
||||
|
||||
Promise.all = function(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(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(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(new TypeError('Promise.race accepts an array'));
|
||||
}
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
Promise.resolve(arr[i]).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn =
|
||||
// @ts-ignore
|
||||
(typeof setImmediate === 'function' &&
|
||||
function(fn) {
|
||||
// @ts-ignore
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
/** @suppress {undefinedVars} */
|
||||
var globalNS = (function() {
|
||||
// the only reliable means to get the global object is
|
||||
// `Function('return this')()`
|
||||
// However, this causes CSP violations in Chrome apps.
|
||||
if (typeof self !== 'undefined') {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== 'undefined') {
|
||||
return global;
|
||||
}
|
||||
throw new Error('unable to locate global object');
|
||||
})();
|
||||
|
||||
if (!('Promise' in globalNS)) {
|
||||
globalNS['Promise'] = Promise;
|
||||
} else if (!globalNS.Promise.prototype['finally']) {
|
||||
globalNS.Promise.prototype['finally'] = finallyConstructor;
|
||||
}
|
||||
|
||||
})));
|
1
node_modules/promise-polyfill/dist/polyfill.min.js
generated
vendored
Normal file
1
node_modules/promise-polyfill/dist/polyfill.min.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(e){return!(!e||"undefined"==typeof e.length)}function t(){}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=[],c(e,this)}function r(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(r){return void f(n.promise,r)}i(n.promise,o)}else(1===e._state?i:f)(n.promise,e._value)})):e._deferreds.push(n)}function i(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 t=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof t)return void c(function(e,n){return function(){e.apply(n,arguments)}}(t,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;t>n;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e(function(e){t||(t=!0,i(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype["finally"]=e,o.all=function(e){return new o(function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,function(n){r(e,n)},o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])})},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(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=o});
|
274
node_modules/promise-polyfill/lib/index.js
generated
vendored
Normal file
274
node_modules/promise-polyfill/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,274 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @this {Promise}
|
||||
*/
|
||||
function finallyConstructor(callback) {
|
||||
var constructor = this.constructor;
|
||||
return this.then(
|
||||
function(value) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
return value;
|
||||
});
|
||||
},
|
||||
function(reason) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
// @ts-ignore
|
||||
return constructor.reject(reason);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Store setTimeout reference so promise-polyfill will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function isArray(x) {
|
||||
return Boolean(x && typeof x.length !== 'undefined');
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function() {
|
||||
fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Function} fn
|
||||
*/
|
||||
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');
|
||||
/** @type {!number} */
|
||||
this._state = 0;
|
||||
/** @type {!boolean} */
|
||||
this._handled = false;
|
||||
/** @type {Promise|undefined} */
|
||||
this._value = undefined;
|
||||
/** @type {!Array<!Function>} */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
// @ts-ignore
|
||||
var prom = new this.constructor(noop);
|
||||
|
||||
handle(this, new Handler(onFulfilled, onRejected, prom));
|
||||
return prom;
|
||||
};
|
||||
|
||||
Promise.prototype['finally'] = finallyConstructor;
|
||||
|
||||
Promise.all = function(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(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(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(new TypeError('Promise.race accepts an array'));
|
||||
}
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
Promise.resolve(arr[i]).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn =
|
||||
// @ts-ignore
|
||||
(typeof setImmediate === 'function' &&
|
||||
function(fn) {
|
||||
// @ts-ignore
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Promise;
|
295
node_modules/promise-polyfill/lib/polyfill.js
generated
vendored
Normal file
295
node_modules/promise-polyfill/lib/polyfill.js
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @this {Promise}
|
||||
*/
|
||||
function finallyConstructor(callback) {
|
||||
var constructor = this.constructor;
|
||||
return this.then(
|
||||
function(value) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
return value;
|
||||
});
|
||||
},
|
||||
function(reason) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
// @ts-ignore
|
||||
return constructor.reject(reason);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Store setTimeout reference so promise-polyfill will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function isArray(x) {
|
||||
return Boolean(x && typeof x.length !== 'undefined');
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function() {
|
||||
fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Function} fn
|
||||
*/
|
||||
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');
|
||||
/** @type {!number} */
|
||||
this._state = 0;
|
||||
/** @type {!boolean} */
|
||||
this._handled = false;
|
||||
/** @type {Promise|undefined} */
|
||||
this._value = undefined;
|
||||
/** @type {!Array<!Function>} */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
// @ts-ignore
|
||||
var prom = new this.constructor(noop);
|
||||
|
||||
handle(this, new Handler(onFulfilled, onRejected, prom));
|
||||
return prom;
|
||||
};
|
||||
|
||||
Promise.prototype['finally'] = finallyConstructor;
|
||||
|
||||
Promise.all = function(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(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(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(new TypeError('Promise.race accepts an array'));
|
||||
}
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
Promise.resolve(arr[i]).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn =
|
||||
// @ts-ignore
|
||||
(typeof setImmediate === 'function' &&
|
||||
function(fn) {
|
||||
// @ts-ignore
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
/** @suppress {undefinedVars} */
|
||||
var globalNS = (function() {
|
||||
// the only reliable means to get the global object is
|
||||
// `Function('return this')()`
|
||||
// However, this causes CSP violations in Chrome apps.
|
||||
if (typeof self !== 'undefined') {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== 'undefined') {
|
||||
return global;
|
||||
}
|
||||
throw new Error('unable to locate global object');
|
||||
})();
|
||||
|
||||
if (!('Promise' in globalNS)) {
|
||||
globalNS['Promise'] = Promise;
|
||||
} else if (!globalNS.Promise.prototype['finally']) {
|
||||
globalNS.Promise.prototype['finally'] = finallyConstructor;
|
||||
}
|
99
node_modules/promise-polyfill/package.json
generated
vendored
Normal file
99
node_modules/promise-polyfill/package.json
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"promise-polyfill@8.1.3",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "promise-polyfill@8.1.3",
|
||||
"_id": "promise-polyfill@8.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g==",
|
||||
"_location": "/promise-polyfill",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "promise-polyfill@8.1.3",
|
||||
"name": "promise-polyfill",
|
||||
"escapedName": "promise-polyfill",
|
||||
"rawSpec": "8.1.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "8.1.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@firebase/polyfill"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz",
|
||||
"_spec": "8.1.3",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Taylor Hakes"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/taylorhakes/promise-polyfill/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Lightweight promise polyfill. A+ compliant",
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"cross-env": "^5.1.1",
|
||||
"eslint": "^4.11.0",
|
||||
"google-closure-compiler": "^20180610.0.1",
|
||||
"husky": "^0.14.3",
|
||||
"karma": "^4.1.0",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^0.2.2",
|
||||
"karma-mocha": "^0.2.1",
|
||||
"lint-staged": "^5.0.0",
|
||||
"mocha": "^6.1.4",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "^1.8.2",
|
||||
"promises-aplus-tests": "*",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.52.0",
|
||||
"rollup-plugin-uglify": "^2.0.1",
|
||||
"sinon": "^1.17.2",
|
||||
"typescript": "^3.5.1",
|
||||
"watchify": "^3.11.1"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"lib",
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/taylorhakes/promise-polyfill",
|
||||
"jsnext:main": "src/index.js",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"promise-polyfill",
|
||||
"ES6",
|
||||
"promises-aplus"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"module": "src/index.js",
|
||||
"name": "promise-polyfill",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/taylorhakes/promise-polyfill.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "run-p build:**",
|
||||
"build:cjs": "rollup -i src/index.js -o lib/index.js -f cjs",
|
||||
"build:cjs-polyfill": "rollup -i src/polyfill.js -o lib/polyfill.js -f cjs",
|
||||
"build:umd-polyfill": "cross-env NODE_ENV=development rollup -i src/polyfill.js -o dist/polyfill.js -c rollup.umd.config.js",
|
||||
"build:umd-polyfill:min": "cross-env NODE_ENV=production rollup -i src/polyfill.js -o dist/polyfill.min.js -c rollup.umd.config.js",
|
||||
"closure": "google-closure-compiler --js=src/*.js --checks_only --module_resolution=node --compilation_level=ADVANCED",
|
||||
"lint": "eslint src && npm run closure && npm run typescript",
|
||||
"prebuild": "rimraf lib dist",
|
||||
"precommit": "lint-staged",
|
||||
"prepare": "npm run build",
|
||||
"prepublish": "test $(npm -v | tr . '\\n' | head -n 1) -ge '4' || exit 1",
|
||||
"pretest": "npm run build:cjs",
|
||||
"test": "npm run lint && mocha && karma start --single-run",
|
||||
"typescript": "tsc --checkJS --allowJS --noEmit src/index.js"
|
||||
},
|
||||
"unpkg": "dist/polyfill.min.js",
|
||||
"version": "8.1.3"
|
||||
}
|
23
node_modules/promise-polyfill/src/finally.js
generated
vendored
Normal file
23
node_modules/promise-polyfill/src/finally.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @this {Promise}
|
||||
*/
|
||||
function finallyConstructor(callback) {
|
||||
var constructor = this.constructor;
|
||||
return this.then(
|
||||
function(value) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
return value;
|
||||
});
|
||||
},
|
||||
function(reason) {
|
||||
// @ts-ignore
|
||||
return constructor.resolve(callback()).then(function() {
|
||||
// @ts-ignore
|
||||
return constructor.reject(reason);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default finallyConstructor;
|
252
node_modules/promise-polyfill/src/index.js
generated
vendored
Normal file
252
node_modules/promise-polyfill/src/index.js
generated
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
import promiseFinally from './finally';
|
||||
|
||||
// Store setTimeout reference so promise-polyfill will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
var setTimeoutFunc = setTimeout;
|
||||
|
||||
function isArray(x) {
|
||||
return Boolean(x && typeof x.length !== 'undefined');
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Polyfill for Function.prototype.bind
|
||||
function bind(fn, thisArg) {
|
||||
return function() {
|
||||
fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Function} fn
|
||||
*/
|
||||
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');
|
||||
/** @type {!number} */
|
||||
this._state = 0;
|
||||
/** @type {!boolean} */
|
||||
this._handled = false;
|
||||
/** @type {Promise|undefined} */
|
||||
this._value = undefined;
|
||||
/** @type {!Array<!Function>} */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
// @ts-ignore
|
||||
var prom = new this.constructor(noop);
|
||||
|
||||
handle(this, new Handler(onFulfilled, onRejected, prom));
|
||||
return prom;
|
||||
};
|
||||
|
||||
Promise.prototype['finally'] = promiseFinally;
|
||||
|
||||
Promise.all = function(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(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(arr) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!isArray(arr)) {
|
||||
return reject(new TypeError('Promise.race accepts an array'));
|
||||
}
|
||||
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
Promise.resolve(arr[i]).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Use polyfill for setImmediate for performance gains
|
||||
Promise._immediateFn =
|
||||
// @ts-ignore
|
||||
(typeof setImmediate === 'function' &&
|
||||
function(fn) {
|
||||
// @ts-ignore
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
export default Promise;
|
25
node_modules/promise-polyfill/src/polyfill.js
generated
vendored
Normal file
25
node_modules/promise-polyfill/src/polyfill.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import Promise from './index';
|
||||
import promiseFinally from './finally';
|
||||
|
||||
/** @suppress {undefinedVars} */
|
||||
var globalNS = (function() {
|
||||
// the only reliable means to get the global object is
|
||||
// `Function('return this')()`
|
||||
// However, this causes CSP violations in Chrome apps.
|
||||
if (typeof self !== 'undefined') {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== 'undefined') {
|
||||
return global;
|
||||
}
|
||||
throw new Error('unable to locate global object');
|
||||
})();
|
||||
|
||||
if (!('Promise' in globalNS)) {
|
||||
globalNS['Promise'] = Promise;
|
||||
} else if (!globalNS.Promise.prototype['finally']) {
|
||||
globalNS.Promise.prototype['finally'] = promiseFinally;
|
||||
}
|
Reference in New Issue
Block a user