source: trip-planner-front/node_modules/csso/lib/restructure/prepare/createDeclarationIndexer.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 598 bytes
Line 
1var generate = require('css-tree').generate;
2
3function Index() {
4 this.seed = 0;
5 this.map = Object.create(null);
6}
7
8Index.prototype.resolve = function(str) {
9 var index = this.map[str];
10
11 if (!index) {
12 index = ++this.seed;
13 this.map[str] = index;
14 }
15
16 return index;
17};
18
19module.exports = function createDeclarationIndexer() {
20 var ids = new Index();
21
22 return function markDeclaration(node) {
23 var id = generate(node);
24
25 node.id = ids.resolve(id);
26 node.length = id.length;
27 node.fingerprint = null;
28
29 return node;
30 };
31};
Note: See TracBrowser for help on using the repository browser.