Imported Debian patch 4.6.2-4~numeezy
This commit is contained in:
committed by
Mario Fetka
parent
8ff3be4216
commit
c86f4cfde4
133
debian/missing-sources/dojo/promise/Promise.js
vendored
Normal file
133
debian/missing-sources/dojo/promise/Promise.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
define([
|
||||
"../_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]";
|
||||
}
|
||||
});
|
||||
});
|
||||
76
debian/missing-sources/dojo/promise/all.js
vendored
Normal file
76
debian/missing-sources/dojo/promise/all.js
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
define([
|
||||
"../_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
|
||||
};
|
||||
});
|
||||
105
debian/missing-sources/dojo/promise/instrumentation.js
vendored
Normal file
105
debian/missing-sources/dojo/promise/instrumentation.js
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
define([
|
||||
"./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 + ">");
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
85
debian/missing-sources/dojo/promise/tracer.js
vendored
Normal file
85
debian/missing-sources/dojo/promise/tracer.js
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
define([
|
||||
"../_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;
|
||||
});
|
||||
Reference in New Issue
Block a user