mirror of
https://github.com/davidmarkclements/0x.git
synced 2026-01-25 14:47:55 +00:00
This also moves the main filter logic into the executed function. This seemed cleaner instead of having to do this in the receiving part.
30 lines
860 B
JavaScript
30 lines
860 B
JavaScript
'use strict'
|
|
|
|
Error.stackTraceLimit = Infinity;
|
|
try {
|
|
throw new Error();
|
|
} catch (err) {
|
|
process.nextTick(() => {
|
|
Error.stackTraceLimit = 2;
|
|
try {
|
|
throw new Error();
|
|
} catch (innerErr) {
|
|
const filterNextTick = innerErr.stack.split('\n')[2].match(/ \(.+?:/g)[0].slice(2);
|
|
const stacks = err.stack
|
|
.match(/ \(.+?:/g)
|
|
.map((e) => e.slice(2))
|
|
// Filter Everything that has nothing to do with Node core and next
|
|
// ticks.
|
|
.filter((e) => e[0] !== '/' && e[0] !== '\\' && e !== filterNextTick);
|
|
let regExpStr = '';
|
|
let separator = '';
|
|
for (const frame of new Set(stacks)) {
|
|
regExpStr += `${separator} ${frame.replace(/\\/g, '\\\\').replace(/\./g, '\\.')}\\d+:\\d+`;
|
|
separator = '|';
|
|
}
|
|
regExpStr += '$';
|
|
console.log(regExpStr);
|
|
}
|
|
});
|
|
}
|