1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 04:26:00 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions

106
node_modules/when/monitor/ConsoleReporter.js generated vendored Normal file
View File

@ -0,0 +1,106 @@
/** @license MIT License (c) copyright 2010-2014 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
(function(define) { 'use strict';
define(function(require) {
var error = require('./error');
var unhandledRejectionsMsg = '[promises] Unhandled rejections: ';
var allHandledMsg = '[promises] All previously unhandled rejections have now been handled';
function ConsoleReporter() {
this._previouslyReported = false;
}
ConsoleReporter.prototype = initDefaultLogging();
ConsoleReporter.prototype.log = function(traces) {
if(traces.length === 0) {
if(this._previouslyReported) {
this._previouslyReported = false;
this.msg(allHandledMsg);
}
return;
}
this._previouslyReported = true;
this.groupStart(unhandledRejectionsMsg + traces.length);
try {
this._log(traces);
} finally {
this.groupEnd();
}
};
ConsoleReporter.prototype._log = function(traces) {
for(var i=0; i<traces.length; ++i) {
this.warn(error.format(traces[i]));
}
};
function initDefaultLogging() {
/*jshint maxcomplexity:7*/
var log, warn, groupStart, groupEnd;
if(typeof console === 'undefined') {
log = warn = consoleNotAvailable;
} else {
// Alias console to prevent things like uglify's drop_console option from
// removing console.log/error. Unhandled rejections fall into the same
// category as uncaught exceptions, and build tools shouldn't silence them.
var localConsole = console;
if(typeof localConsole.error === 'function'
&& typeof localConsole.dir === 'function') {
warn = function(s) {
localConsole.error(s);
};
log = function(s) {
localConsole.log(s);
};
if(typeof localConsole.groupCollapsed === 'function') {
groupStart = function(s) {
localConsole.groupCollapsed(s);
};
groupEnd = function() {
localConsole.groupEnd();
};
}
} else {
// IE8 has console.log and JSON, so we can make a
// reasonably useful warn() from those.
// Credit to webpro (https://github.com/webpro) for this idea
// typeof localConsole.log will return 'object' in IE8, so can't test it with === 'function'
// Since this is more of a corner case for IE8, I'm ok to check it with !== 'undefined' to reduce complexity
if (typeof localConsole.log !== 'undefined' && typeof JSON !== 'undefined') {
log = warn = function(x) {
if (typeof x !== 'string') {
try {
x = JSON.stringify(x);
} catch (e) {
}
}
localConsole.log(x);
};
} else {
log = warn = consoleNotAvailable;
}
}
}
return {
msg: log,
warn: warn,
groupStart: groupStart || warn,
groupEnd: groupEnd || consoleNotAvailable
};
}
function consoleNotAvailable() {}
return ConsoleReporter;
});
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));

197
node_modules/when/monitor/PromiseMonitor.js generated vendored Normal file
View File

@ -0,0 +1,197 @@
/** @license MIT License (c) copyright 2010-2014 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
(function(define) { 'use strict';
define(function(require) {
var defaultStackJumpSeparator = 'from execution context:';
var defaultStackFilter = /[\s\(\/\\](node|module|timers)\.js:|when([\/\\]{1,2}(lib|monitor|es6-shim)[\/\\]{1,2}|\.js)|(new\sPromise)\b|(\b(PromiseMonitor|ConsoleReporter|Scheduler|RunHandlerTask|ProgressTask|Promise|.*Handler)\.[\w_]\w\w+\b)|\b(tryCatch\w+|getHandler\w*)\b/i;
var setTimer = require('../lib/env').setTimer;
var error = require('./error');
var executionContext = [];
function PromiseMonitor(reporter) {
this.logDelay = 0;
this.stackFilter = defaultStackFilter;
this.stackJumpSeparator = defaultStackJumpSeparator;
this.filterDuplicateFrames = true;
this._reporter = reporter;
if(typeof reporter.configurePromiseMonitor === 'function') {
reporter.configurePromiseMonitor(this);
}
this._traces = [];
this._traceTask = 0;
var self = this;
this._doLogTraces = function() {
self._logTraces();
};
}
PromiseMonitor.prototype.monitor = function(Promise) {
var self = this;
Promise.createContext = function(p, context) {
p.context = self.createContext(p, context);
};
Promise.enterContext = function(p) {
executionContext.push(p.context);
};
Promise.exitContext = function() {
executionContext.pop();
};
Promise.onPotentiallyUnhandledRejection = function(rejection, extraContext) {
return self.addTrace(rejection, extraContext);
};
Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
return self.removeTrace(rejection);
};
Promise.onFatalRejection = function(rejection, extraContext) {
return self.fatal(rejection, extraContext);
};
return this;
};
PromiseMonitor.prototype.createContext = function(at, parentContext) {
var context = {
parent: parentContext || executionContext[executionContext.length - 1],
stack: void 0
};
error.captureStack(context, at.constructor);
return context;
};
PromiseMonitor.prototype.addTrace = function(handler, extraContext) {
var t, i;
for(i = this._traces.length-1; i >= 0; --i) {
t = this._traces[i];
if(t.handler === handler) {
break;
}
}
if(i >= 0) {
t.extraContext = extraContext;
} else {
this._traces.push({
handler: handler,
extraContext: extraContext
});
}
this.logTraces();
};
PromiseMonitor.prototype.removeTrace = function(/*handler*/) {
this.logTraces();
};
PromiseMonitor.prototype.fatal = function(handler, extraContext) {
var err = new Error();
err.stack = this._createLongTrace(handler.value, handler.context, extraContext).join('\n');
setTimer(function() {
throw err;
}, 0);
};
PromiseMonitor.prototype.logTraces = function() {
if(!this._traceTask) {
this._traceTask = setTimer(this._doLogTraces, this.logDelay);
}
};
PromiseMonitor.prototype._logTraces = function() {
this._traceTask = void 0;
this._traces = this._traces.filter(filterHandled);
this._reporter.log(this.formatTraces(this._traces));
};
PromiseMonitor.prototype.formatTraces = function(traces) {
return traces.map(function(t) {
return this._createLongTrace(t.handler.value, t.handler.context, t.extraContext);
}, this);
};
PromiseMonitor.prototype._createLongTrace = function(e, context, extraContext) {
var trace = error.parse(e) || [String(e) + ' (WARNING: non-Error used)'];
trace = filterFrames(this.stackFilter, trace, 0);
this._appendContext(trace, context);
this._appendContext(trace, extraContext);
return this.filterDuplicateFrames ? this._removeDuplicates(trace) : trace;
};
PromiseMonitor.prototype._removeDuplicates = function(trace) {
var seen = {};
var sep = this.stackJumpSeparator;
var count = 0;
return trace.reduceRight(function(deduped, line, i) {
if(i === 0) {
deduped.unshift(line);
} else if(line === sep) {
if(count > 0) {
deduped.unshift(line);
count = 0;
}
} else if(!seen[line]) {
seen[line] = true;
deduped.unshift(line);
++count;
}
return deduped;
}, []);
};
PromiseMonitor.prototype._appendContext = function(trace, context) {
trace.push.apply(trace, this._createTrace(context));
};
PromiseMonitor.prototype._createTrace = function(traceChain) {
var trace = [];
var stack;
while(traceChain) {
stack = error.parse(traceChain);
if (stack) {
stack = filterFrames(this.stackFilter, stack);
appendStack(trace, stack, this.stackJumpSeparator);
}
traceChain = traceChain.parent;
}
return trace;
};
function appendStack(trace, stack, separator) {
if (stack.length > 1) {
stack[0] = separator;
trace.push.apply(trace, stack);
}
}
function filterFrames(stackFilter, stack) {
return stack.filter(function(frame) {
return !stackFilter.test(frame);
});
}
function filterHandled(t) {
return !t.handler.handled;
}
return PromiseMonitor;
});
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));

3
node_modules/when/monitor/README.md generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Promise monitoring and debugging
This dir contains experimental new promise monitoring and debugging utilities for when.js. See [the docs](../docs/api.md#debugging-promises).

14
node_modules/when/monitor/console.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
/** @license MIT License (c) copyright 2010-2014 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
(function(define) { 'use strict';
define(function(require) {
var monitor = require('../monitor');
var Promise = require('../when').Promise;
return monitor(Promise);
});
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));

86
node_modules/when/monitor/error.js generated vendored Normal file
View File

@ -0,0 +1,86 @@
/** @license MIT License (c) copyright 2010-2014 original author or authors */
/** @author Brian Cavalier */
/** @author John Hann */
(function(define) { 'use strict';
define(function() {
var parse, captureStack, format;
if(Error.captureStackTrace) {
// Use Error.captureStackTrace if available
parse = function(e) {
return e && e.stack && e.stack.split('\n');
};
format = formatAsString;
captureStack = Error.captureStackTrace;
} else {
// Otherwise, do minimal feature detection to determine
// how to capture and format reasonable stacks.
parse = function(e) {
var stack = e && e.stack && e.stack.split('\n');
if(stack && e.message) {
stack.unshift(e.message);
}
return stack;
};
(function() {
var e = new Error();
if(typeof e.stack !== 'string') {
format = formatAsString;
captureStack = captureSpiderMonkeyStack;
} else {
format = formatAsErrorWithStack;
captureStack = useStackDirectly;
}
}());
}
function captureSpiderMonkeyStack(host) {
try {
throw new Error();
} catch(err) {
host.stack = err.stack;
}
}
function useStackDirectly(host) {
host.stack = new Error().stack;
}
function formatAsString(longTrace) {
return join(longTrace);
}
function formatAsErrorWithStack(longTrace) {
var e = new Error();
e.stack = formatAsString(longTrace);
return e;
}
// About 5-10x faster than String.prototype.join o_O
function join(a) {
var sep = false;
var s = '';
for(var i=0; i< a.length; ++i) {
if(sep) {
s += '\n' + a[i];
} else {
s+= a[i];
sep = true;
}
}
return s;
}
return {
parse: parse,
format: format,
captureStack: captureStack
};
});
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));