You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
538 B
JavaScript
22 lines
538 B
JavaScript
'use strict';
|
|
|
|
module.exports = function collapseIgnored(stack) {
|
|
let sawIgnored = false;
|
|
|
|
return stack.reduce((newStack, stackLine) => {
|
|
if (stackLine.type === "ignored") {
|
|
if (sawIgnored === false) {
|
|
sawIgnored = true;
|
|
newStack.push(stackLine);
|
|
} else {
|
|
newStack[newStack.length - 1].count += 1;
|
|
}
|
|
} else {
|
|
sawIgnored = false;
|
|
newStack.push(stackLine);
|
|
}
|
|
|
|
return newStack;
|
|
}, []);
|
|
};
|