.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-stringify / lib / util / entity-prefix-length.js
1 'use strict';
2
3 var decode = require('parse-entities');
4
5 module.exports = length;
6
7 /* Returns the length of HTML entity that is a prefix of
8  * the given string (excluding the ampersand), 0 if it
9  * does not start with an entity. */
10 function length(value) {
11   var prefix;
12
13   /* istanbul ignore if - Currently also tested for at
14    * implemention, but we keep it here because that’s
15    * proper. */
16   if (value.charAt(0) !== '&') {
17     return 0;
18   }
19
20   prefix = value.split('&', 2).join('&');
21
22   return prefix.length - decode(prefix).length;
23 }