Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.preprocess = function(tokens) {
var good = [];
// Traverse tokens in reverse so that tokens in front, which will
// be used to compare `followedBy` and `notFollowedBy` groups,
// are already processed.
for (var i = tokens.length - 1; i >= 0; i--) {
var token = tokens[i];
if (token.type === types.GROUP || token.type === types.ROOT) {
if (token.followedBy || token.notFollowedBy) {
if (token.options) {
token.options = token.options.map(exports.preprocess);
good = [{
type: types.GROUP,
options: token.options.map(function(stack) {
return addTokenList(stack, good, !!token.followedBy);
}),
}];
} else if (token.stack) {
token.stack = exports.preprocess(token.stack);
good = addTokenList(token.stack, good, !!token.followedBy);
}
} else {
good.unshift(exports.preprocessGroup(token));
}
} else {
good.unshift(token);
}
}