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.

23 lines
429 B
JavaScript

'use strict';
const format = require("./format-flattened-query");
module.exports = function tagQuerySegments(queries) {
let tagMap = {};
let currentTag = 0;
queries.forEach((query) => {
let stack = [];
query.forEach((segment) => {
stack.push(segment);
let formatted = format(stack);
if (tagMap[formatted] == null) {
tagMap[formatted] = currentTag++;
}
segment.tag = tagMap[formatted];
});
});
}