2 module.exports = function(Promise, CapturedTrace, isDebugging) {
5 this._trace = new CapturedTrace(peekContext());
7 Context.prototype._pushContext = function () {
8 if (!isDebugging()) return;
9 if (this._trace !== undefined) {
10 contextStack.push(this._trace);
14 Context.prototype._popContext = function () {
15 if (!isDebugging()) return;
16 if (this._trace !== undefined) {
21 function createContext() {
22 if (isDebugging()) return new Context();
25 function peekContext() {
26 var lastIndex = contextStack.length - 1;
28 return contextStack[lastIndex];
33 Promise.prototype._peekContext = peekContext;
34 Promise.prototype._pushContext = Context.prototype._pushContext;
35 Promise.prototype._popContext = Context.prototype._popContext;