.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-parse / lib / util / get-indentation.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-parse/lib/util/get-indentation.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-parse/lib/util/get-indentation.js
new file mode 100644 (file)
index 0000000..3e09e14
--- /dev/null
@@ -0,0 +1,32 @@
+'use strict';
+
+module.exports = indentation;
+
+/* Map of characters, and their column length,
+ * which can be used as indentation. */
+var characters = {' ': 1, '\t': 4};
+
+/* Gets indentation information for a line. */
+function indentation(value) {
+  var index = 0;
+  var indent = 0;
+  var character = value.charAt(index);
+  var stops = {};
+  var size;
+
+  while (character in characters) {
+    size = characters[character];
+
+    indent += size;
+
+    if (size > 1) {
+      indent = Math.floor(indent / size) * size;
+    }
+
+    stops[indent] = index;
+
+    character = value.charAt(++index);
+  }
+
+  return {indent: indent, stops: stops};
+}