.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-parse / lib / util / get-indentation.js
1 'use strict';
2
3 module.exports = indentation;
4
5 /* Map of characters, and their column length,
6  * which can be used as indentation. */
7 var characters = {' ': 1, '\t': 4};
8
9 /* Gets indentation information for a line. */
10 function indentation(value) {
11   var index = 0;
12   var indent = 0;
13   var character = value.charAt(index);
14   var stops = {};
15   var size;
16
17   while (character in characters) {
18     size = characters[character];
19
20     indent += size;
21
22     if (size > 1) {
23       indent = Math.floor(indent / size) * size;
24     }
25
26     stops[indent] = index;
27
28     character = value.charAt(++index);
29   }
30
31   return {indent: indent, stops: stops};
32 }