5 * Create a collection of Maps that serve to contextualize a given node.
6 * This is useful to ensure that you only compare nodes that share a certain
9 * All nodes are initially contextualized by their input source.
10 * From there, you can contextualize them however you want.
12 * For a usage example, see `selector-no-descending-specificity`.
14 module.exports = function() {
15 const contextMap = new Map();
19 const nodeSource = node.source.input.from;
20 const baseContext = creativeGetMap(contextMap, nodeSource);
21 const subContexts = Array.from(arguments).slice(1);
23 return subContexts.reduce((result, context) => {
24 return creativeGetMap(result, context);
30 function creativeGetMap(someMap, someThing) {
31 if (!someMap.has(someThing)) {
32 someMap.set(someThing, new Map());
34 return someMap.get(someThing);