This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wtf): add wtf support to (set/clear)Timeout/Interval/Immediate
This rewrites the (set/clear)Timeout/Interval/Immediate method to render information in WTF. It also makes the code more explicit, by removing the need for bind method and instead creating explicit callbacks. The resulting code is faster, and easier to read and reason about.
- Loading branch information
Showing
12 changed files
with
291 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
// Detect and setup WTF. | ||
var wtfTrace = null; | ||
var wtfEvents = null; | ||
var wtfEnabled = (function () { | ||
var wtf = global['wtf']; | ||
if (wtf) { | ||
wtfTrace = wtf['trace']; | ||
if (wtfTrace) { | ||
wtfEvents = wtfTrace['events']; | ||
return true; | ||
} | ||
} | ||
return false; | ||
})(); | ||
|
||
function noop() { | ||
} | ||
|
||
if (wtfEnabled) { | ||
module.exports = { | ||
enabled: true, | ||
createScope: function (signature, flags) { | ||
return wtfEvents.createScope(signature, flags); | ||
}, | ||
createEvent: function (signature, flags) { | ||
return wtfEvents.createInstance(signature, flags); | ||
}, | ||
leaveScope: function (scope, returnValue) { | ||
wtfTrace.leaveScope(scope, returnValue); | ||
return returnValue; | ||
}, | ||
beginTimeRange:function (rangeType, action) { | ||
return wtfTrace.beginTimeRange(rangeType, action); | ||
}, | ||
endTimeRange: function (range) { | ||
wtfTrace.endTimeRange(range); | ||
} | ||
}; | ||
} else { | ||
module.exports = { | ||
enabled: false, | ||
createScope: function (s, f) { return noop; }, | ||
createEvent: function (s, f) { return noop; }, | ||
leaveScope: function (s, v) { return v; }, | ||
beginTimeRange: function (t, a) { return null; }, | ||
endTimeRange: function (r) { } | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.