/usr/lib/thunderbird-addons/extensions/{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}/modules/shim/PromiseExtras.jsm is in xul-ext-gdata-provider 1:52.7.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["PromiseAll"];
Components.utils.import("resource://gdata-provider/modules/shim/Loader.jsm");
CuImport("resource://gre/modules/Promise.jsm", this);
CuImport("resource://gre/modules/PromiseUtils.jsm", this);
/**
* Shim for Promise.all needed for Gecko 24. Unfortunately the Promise object
* is frozen, so we need to export this directly.
*/
var PromiseAll;
if (typeof Promise.all == "function") {
PromiseAll = Promise.all.bind(Promise);
} else {
PromiseAll = function (aValues) {
if (typeof Promise.all == "function") {
return Promise.all(aValues);
}
function checkForCompletion(aValue, aIndex) {
resolutionValues[aIndex] = aValue;
if (--countdown === 0) {
deferred.resolve(resolutionValues);
}
}
if (aValues == null || !Array.isArray(aValues)) {
throw new Error("Promise.all() expects an array.");
}
let values = aValues;
let countdown = values.length;
let resolutionValues = new Array(countdown);
if (!countdown) {
return Promise.resolve(resolutionValues);
}
let deferred = PromiseUtils.defer();
for (let i = 0; i < values.length; i++) {
let index = i;
let value = values[i];
let resolver = function(val) { return checkForCompletion(val, index); };
if (value && typeof(value.then) == "function") {
value.then(resolver, deferred.reject);
} else {
// Given value is not a promise, forward it as a resolution value.
resolver(value);
}
}
return deferred.promise;
};
}
|