mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-09 00:08:18 +08:00
c23ba31e17
Thread dropdown Small fixes
33 lines
737 B
JavaScript
33 lines
737 B
JavaScript
|
|
var Promise = function () {
|
|
};
|
|
|
|
var isPromise = function (value) {
|
|
return value instanceof Promise;
|
|
};
|
|
|
|
var defer = function () {
|
|
var pending = [], value;
|
|
var promise = new Promise();
|
|
promise.then = function (callback) {
|
|
if (pending) {
|
|
pending.push(callback);
|
|
} else {
|
|
callback(value);
|
|
}
|
|
};
|
|
return {
|
|
resolve: function (_value) {
|
|
if (pending) {
|
|
value = _value;
|
|
for (var i = 0, ii = pending.length; i < ii; i++) {
|
|
var callback = pending[i];
|
|
callback(value);
|
|
}
|
|
pending = undefined;
|
|
}
|
|
},
|
|
promise: promise
|
|
};
|
|
};
|
|
|