3 var decode = require('parse-entities');
5 module.exports = length;
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) {
13 /* istanbul ignore if - Currently also tested for at
14 * implemention, but we keep it here because that’s
16 if (value.charAt(0) !== '&') {
20 prefix = value.split('&', 2).join('&');
22 return prefix.length - decode(prefix).length;