summaryrefslogtreecommitdiff
path: root/lib/dojo/promise
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-02 20:06:16 +0400
committerAndrew Dolgov <[email protected]>2013-04-02 20:06:16 +0400
commit870334be3f58507c05bfc72f3edbe5db10af4caf (patch)
tree441e1c41780eb75d422025cabea17724e2cc4a79 /lib/dojo/promise
parent7caa48fe6a3a37bd08f846f90e407ef31171f12c (diff)
remove dojo uncompressed files
Diffstat (limited to 'lib/dojo/promise')
-rw-r--r--lib/dojo/promise/Promise.js.uncompressed.js133
-rw-r--r--lib/dojo/promise/all.js.uncompressed.js76
-rw-r--r--lib/dojo/promise/first.js.uncompressed.js49
-rw-r--r--lib/dojo/promise/instrumentation.js.uncompressed.js105
-rw-r--r--lib/dojo/promise/tracer.js.uncompressed.js85
5 files changed, 0 insertions, 448 deletions
diff --git a/lib/dojo/promise/Promise.js.uncompressed.js b/lib/dojo/promise/Promise.js.uncompressed.js
deleted file mode 100644
index eba0080fd..000000000
--- a/lib/dojo/promise/Promise.js.uncompressed.js
+++ /dev/null
@@ -1,133 +0,0 @@
-define("dojo/promise/Promise", [
- "../_base/lang"
-], function(lang){
- "use strict";
-
- // module:
- // dojo/promise/Promise
-
- function throwAbstract(){
- throw new TypeError("abstract");
- }
-
- return lang.extend(function Promise(){
- // summary:
- // The public interface to a deferred.
- // description:
- // The public interface to a deferred. All promises in Dojo are
- // instances of this class.
- }, {
- then: function(callback, errback, progback){
- // summary:
- // Add new callbacks to the promise.
- // description:
- // Add new callbacks to the deferred. Callbacks can be added
- // before or after the deferred is fulfilled.
- // callback: Function?
- // Callback to be invoked when the promise is resolved.
- // Receives the resolution value.
- // errback: Function?
- // Callback to be invoked when the promise is rejected.
- // Receives the rejection error.
- // progback: Function?
- // Callback to be invoked when the promise emits a progress
- // update. Receives the progress update.
- // returns: dojo/promise/Promise
- // Returns a new promise for the result of the callback(s).
- // This can be used for chaining many asynchronous operations.
-
- throwAbstract();
- },
-
- cancel: function(reason, strict){
- // summary:
- // Inform the deferred it may cancel its asynchronous operation.
- // description:
- // Inform the deferred it may cancel its asynchronous operation.
- // The deferred's (optional) canceler is invoked and the
- // deferred will be left in a rejected state. Can affect other
- // promises that originate with the same deferred.
- // reason: any
- // A message that may be sent to the deferred's canceler,
- // explaining why it's being canceled.
- // strict: Boolean?
- // If strict, will throw an error if the deferred has already
- // been fulfilled and consequently cannot be canceled.
- // returns: any
- // Returns the rejection reason if the deferred was canceled
- // normally.
-
- throwAbstract();
- },
-
- isResolved: function(){
- // summary:
- // Checks whether the promise has been resolved.
- // returns: Boolean
-
- throwAbstract();
- },
-
- isRejected: function(){
- // summary:
- // Checks whether the promise has been rejected.
- // returns: Boolean
-
- throwAbstract();
- },
-
- isFulfilled: function(){
- // summary:
- // Checks whether the promise has been resolved or rejected.
- // returns: Boolean
-
- throwAbstract();
- },
-
- isCanceled: function(){
- // summary:
- // Checks whether the promise has been canceled.
- // returns: Boolean
-
- throwAbstract();
- },
-
- always: function(callbackOrErrback){
- // summary:
- // Add a callback to be invoked when the promise is resolved
- // or rejected.
- // callbackOrErrback: Function?
- // A function that is used both as a callback and errback.
- // returns: dojo/promise/Promise
- // Returns a new promise for the result of the callback/errback.
-
- return this.then(callbackOrErrback, callbackOrErrback);
- },
-
- otherwise: function(errback){
- // summary:
- // Add new errbacks to the promise.
- // errback: Function?
- // Callback to be invoked when the promise is rejected.
- // returns: dojo/promise/Promise
- // Returns a new promise for the result of the errback.
-
- return this.then(null, errback);
- },
-
- trace: function(){
- return this;
- },
-
- traceRejected: function(){
- return this;
- },
-
- toString: function(){
- // returns: string
- // Returns `[object Promise]`.
-
- return "[object Promise]";
- }
- });
-});
diff --git a/lib/dojo/promise/all.js.uncompressed.js b/lib/dojo/promise/all.js.uncompressed.js
deleted file mode 100644
index 278f604a6..000000000
--- a/lib/dojo/promise/all.js.uncompressed.js
+++ /dev/null
@@ -1,76 +0,0 @@
-define("dojo/promise/all", [
- "../_base/array",
- "../Deferred",
- "../when"
-], function(array, Deferred, when){
- "use strict";
-
- // module:
- // dojo/promise/all
-
- var some = array.some;
-
- return function all(objectOrArray){
- // summary:
- // Takes multiple promises and returns a new promise that is fulfilled
- // when all promises have been fulfilled.
- // description:
- // Takes multiple promises and returns a new promise that is fulfilled
- // when all promises have been fulfilled. If one of the promises is rejected,
- // the returned promise is also rejected. Canceling the returned promise will
- // *not* cancel any passed promises.
- // objectOrArray: Object|Array?
- // The promise will be fulfilled with a list of results if invoked with an
- // array, or an object of results when passed an object (using the same
- // keys). If passed neither an object or array it is resolved with an
- // undefined value.
- // returns: dojo/promise/Promise
-
- var object, array;
- if(objectOrArray instanceof Array){
- array = objectOrArray;
- }else if(objectOrArray && typeof objectOrArray === "object"){
- object = objectOrArray;
- }
-
- var results;
- var keyLookup = [];
- if(object){
- array = [];
- for(var key in object){
- if(Object.hasOwnProperty.call(object, key)){
- keyLookup.push(key);
- array.push(object[key]);
- }
- }
- results = {};
- }else if(array){
- results = [];
- }
-
- if(!array || !array.length){
- return new Deferred().resolve(results);
- }
-
- var deferred = new Deferred();
- deferred.promise.always(function(){
- results = keyLookup = null;
- });
- var waiting = array.length;
- some(array, function(valueOrPromise, index){
- if(!object){
- keyLookup.push(index);
- }
- when(valueOrPromise, function(value){
- if(!deferred.isFulfilled()){
- results[keyLookup[index]] = value;
- if(--waiting === 0){
- deferred.resolve(results);
- }
- }
- }, deferred.reject);
- return deferred.isFulfilled();
- });
- return deferred.promise; // dojo/promise/Promise
- };
-});
diff --git a/lib/dojo/promise/first.js.uncompressed.js b/lib/dojo/promise/first.js.uncompressed.js
deleted file mode 100644
index 863573fa1..000000000
--- a/lib/dojo/promise/first.js.uncompressed.js
+++ /dev/null
@@ -1,49 +0,0 @@
-define("dojo/promise/first", [
- "../_base/array",
- "../Deferred",
- "../when"
-], function(array, Deferred, when){
- "use strict";
-
- // module:
- // dojo/promise/first
-
- var forEach = array.forEach;
-
- return function first(objectOrArray){
- // summary:
- // Takes multiple promises and returns a new promise that is fulfilled
- // when the first of these promises is fulfilled.
- // description:
- // Takes multiple promises and returns a new promise that is fulfilled
- // when the first of these promises is fulfilled. Canceling the returned
- // promise will *not* cancel any passed promises. The promise will be
- // fulfilled with the value of the first fulfilled promise.
- // objectOrArray: Object|Array?
- // The promises are taken from the array or object values. If no value
- // is passed, the returned promise is resolved with an undefined value.
- // returns: dojo/promise/Promise
-
- var array;
- if(objectOrArray instanceof Array){
- array = objectOrArray;
- }else if(objectOrArray && typeof objectOrArray === "object"){
- array = [];
- for(var key in objectOrArray){
- if(Object.hasOwnProperty.call(objectOrArray, key)){
- array.push(objectOrArray[key]);
- }
- }
- }
-
- if(!array || !array.length){
- return new Deferred().resolve();
- }
-
- var deferred = new Deferred();
- forEach(array, function(valueOrPromise){
- when(valueOrPromise, deferred.resolve, deferred.reject);
- });
- return deferred.promise; // dojo/promise/Promise
- };
-});
diff --git a/lib/dojo/promise/instrumentation.js.uncompressed.js b/lib/dojo/promise/instrumentation.js.uncompressed.js
deleted file mode 100644
index b32bb9841..000000000
--- a/lib/dojo/promise/instrumentation.js.uncompressed.js
+++ /dev/null
@@ -1,105 +0,0 @@
-define("dojo/promise/instrumentation", [
- "./tracer",
- "../has",
- "../_base/lang",
- "../_base/array"
-], function(tracer, has, lang, arrayUtil){
- function logError(error, rejection, deferred){
- var stack = "";
- if(error && error.stack){
- stack += error.stack;
- }
- if(rejection && rejection.stack){
- stack += "\n ----------------------------------------\n rejected" + rejection.stack.split("\n").slice(1).join("\n").replace(/^\s+/, " ");
- }
- if(deferred && deferred.stack){
- stack += "\n ----------------------------------------\n" + deferred.stack;
- }
- console.error(error, stack);
- }
-
- function reportRejections(error, handled, rejection, deferred){
- if(!handled){
- logError(error, rejection, deferred);
- }
- }
-
- var errors = [];
- var activeTimeout = false;
- var unhandledWait = 1000;
- function trackUnhandledRejections(error, handled, rejection, deferred){
- if(handled){
- arrayUtil.some(errors, function(obj, ix){
- if(obj.error === error){
- errors.splice(ix, 1);
- return true;
- }
- });
- }else if(!arrayUtil.some(errors, function(obj){ return obj.error === error; })){
- errors.push({
- error: error,
- rejection: rejection,
- deferred: deferred,
- timestamp: new Date().getTime()
- });
- }
-
- if(!activeTimeout){
- activeTimeout = setTimeout(logRejected, unhandledWait);
- }
- }
-
- function logRejected(){
- var now = new Date().getTime();
- var reportBefore = now - unhandledWait;
- errors = arrayUtil.filter(errors, function(obj){
- if(obj.timestamp < reportBefore){
- logError(obj.error, obj.rejection, obj.deferred);
- return false;
- }
- return true;
- });
-
- if(errors.length){
- activeTimeout = setTimeout(logRejected, errors[0].timestamp + unhandledWait - now);
- }else{
- activeTimeout = false;
- }
- }
-
- return function(Deferred){
- // summary:
- // Initialize instrumentation for the Deferred class.
- // description:
- // Initialize instrumentation for the Deferred class.
- // Done automatically by `dojo/Deferred` if the
- // `deferredInstrumentation` and `useDeferredInstrumentation`
- // config options are set.
- //
- // Sets up `dojo/promise/tracer` to log to the console.
- //
- // Sets up instrumentation of rejected deferreds so unhandled
- // errors are logged to the console.
-
- var usage = has("config-useDeferredInstrumentation");
- if(usage){
- tracer.on("resolved", lang.hitch(console, "log", "resolved"));
- tracer.on("rejected", lang.hitch(console, "log", "rejected"));
- tracer.on("progress", lang.hitch(console, "log", "progress"));
-
- var args = [];
- if(typeof usage === "string"){
- args = usage.split(",");
- usage = args.shift();
- }
- if(usage === "report-rejections"){
- Deferred.instrumentRejected = reportRejections;
- }else if(usage === "report-unhandled-rejections" || usage === true || usage === 1){
- Deferred.instrumentRejected = trackUnhandledRejections;
- unhandledWait = parseInt(args[0], 10) || unhandledWait;
- }else{
- throw new Error("Unsupported instrumentation usage <" + usage + ">");
- }
- }
- };
-});
diff --git a/lib/dojo/promise/tracer.js.uncompressed.js b/lib/dojo/promise/tracer.js.uncompressed.js
deleted file mode 100644
index b5380cc32..000000000
--- a/lib/dojo/promise/tracer.js.uncompressed.js
+++ /dev/null
@@ -1,85 +0,0 @@
-define("dojo/promise/tracer", [
- "../_base/lang",
- "./Promise",
- "../Evented"
-], function(lang, Promise, Evented){
- "use strict";
-
- // module:
- // dojo/promise/tracer
-
- /*=====
- return {
- // summary:
- // Trace promise fulfillment.
- // description:
- // Trace promise fulfillment. Calling `.trace()` or `.traceError()` on a
- // promise enables tracing. Will emit `resolved`, `rejected` or `progress`
- // events.
-
- on: function(type, listener){
- // summary:
- // Subscribe to traces.
- // description:
- // See `dojo/Evented#on()`.
- // type: String
- // `resolved`, `rejected`, or `progress`
- // listener: Function
- // The listener is passed the traced value and any arguments
- // that were used with the `.trace()` call.
- }
- };
- =====*/
-
- var evented = new Evented;
- var emit = evented.emit;
- evented.emit = null;
- // Emit events asynchronously since they should not change the promise state.
- function emitAsync(args){
- setTimeout(function(){
- emit.apply(evented, args);
- }, 0);
- }
-
- Promise.prototype.trace = function(){
- // summary:
- // Trace the promise.
- // description:
- // Tracing allows you to transparently log progress,
- // resolution and rejection of promises, without affecting the
- // promise itself. Any arguments passed to `trace()` are
- // emitted in trace events. See `dojo/promise/tracer` on how
- // to handle traces.
- // returns: dojo/promise/Promise
- // The promise instance `trace()` is called on.
-
- var args = lang._toArray(arguments);
- this.then(
- function(value){ emitAsync(["resolved", value].concat(args)); },
- function(error){ emitAsync(["rejected", error].concat(args)); },
- function(update){ emitAsync(["progress", update].concat(args)); }
- );
- return this;
- };
-
- Promise.prototype.traceRejected = function(){
- // summary:
- // Trace rejection of the promise.
- // description:
- // Tracing allows you to transparently log progress,
- // resolution and rejection of promises, without affecting the
- // promise itself. Any arguments passed to `trace()` are
- // emitted in trace events. See `dojo/promise/tracer` on how
- // to handle traces.
- // returns: dojo/promise/Promise
- // The promise instance `traceRejected()` is called on.
-
- var args = lang._toArray(arguments);
- this.otherwise(function(error){
- emitAsync(["rejected", error].concat(args));
- });
- return this;
- };
-
- return evented;
-});