"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/bluebird/js/main/progress.js" (7 Feb 2017, 2492 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 "use strict";
    2 module.exports = function(Promise, PromiseArray) {
    3 var util = require("./util.js");
    4 var async = require("./async.js");
    5 var tryCatch = util.tryCatch;
    6 var errorObj = util.errorObj;
    7 
    8 Promise.prototype.progressed = function (handler) {
    9     return this._then(undefined, undefined, handler, undefined, undefined);
   10 };
   11 
   12 Promise.prototype._progress = function (progressValue) {
   13     if (this._isFollowingOrFulfilledOrRejected()) return;
   14     this._target()._progressUnchecked(progressValue);
   15 
   16 };
   17 
   18 Promise.prototype._progressHandlerAt = function (index) {
   19     return index === 0
   20         ? this._progressHandler0
   21         : this[(index << 2) + index - 5 + 2];
   22 };
   23 
   24 Promise.prototype._doProgressWith = function (progression) {
   25     var progressValue = progression.value;
   26     var handler = progression.handler;
   27     var promise = progression.promise;
   28     var receiver = progression.receiver;
   29 
   30     var ret = tryCatch(handler).call(receiver, progressValue);
   31     if (ret === errorObj) {
   32         if (ret.e != null &&
   33             ret.e.name !== "StopProgressPropagation") {
   34             var trace = util.canAttachTrace(ret.e)
   35                 ? ret.e : new Error(util.toString(ret.e));
   36             promise._attachExtraTrace(trace);
   37             promise._progress(ret.e);
   38         }
   39     } else if (ret instanceof Promise) {
   40         ret._then(promise._progress, null, null, promise, undefined);
   41     } else {
   42         promise._progress(ret);
   43     }
   44 };
   45 
   46 
   47 Promise.prototype._progressUnchecked = function (progressValue) {
   48     var len = this._length();
   49     var progress = this._progress;
   50     for (var i = 0; i < len; i++) {
   51         var handler = this._progressHandlerAt(i);
   52         var promise = this._promiseAt(i);
   53         if (!(promise instanceof Promise)) {
   54             var receiver = this._receiverAt(i);
   55             if (typeof handler === "function") {
   56                 handler.call(receiver, progressValue, promise);
   57             } else if (receiver instanceof PromiseArray &&
   58                        !receiver._isResolved()) {
   59                 receiver._promiseProgressed(progressValue, promise);
   60             }
   61             continue;
   62         }
   63 
   64         if (typeof handler === "function") {
   65             async.invoke(this._doProgressWith, this, {
   66                 handler: handler,
   67                 promise: promise,
   68                 receiver: this._receiverAt(i),
   69                 value: progressValue
   70             });
   71         } else {
   72             async.invoke(progress, promise, progressValue);
   73         }
   74     }
   75 };
   76 };