Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/node_modules/remark-stringify/lib/util/entity-prefix-length.js')
-rw-r--r--assets/node_modules/remark-stringify/lib/util/entity-prefix-length.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/assets/node_modules/remark-stringify/lib/util/entity-prefix-length.js b/assets/node_modules/remark-stringify/lib/util/entity-prefix-length.js
new file mode 100644
index 0000000..2ba771c
--- /dev/null
+++ b/assets/node_modules/remark-stringify/lib/util/entity-prefix-length.js
@@ -0,0 +1,23 @@
+'use strict'
+
+var decode = require('parse-entities')
+
+module.exports = length
+
+var ampersand = '&'
+
+// Returns the length of HTML entity that is a prefix of the given string
+// (excluding the ampersand), 0 if it does not start with an entity.
+function length(value) {
+ var prefix
+
+ /* istanbul ignore if - Currently also tested for at implemention, but we
+ * keep it here because that’s proper. */
+ if (value.charAt(0) !== ampersand) {
+ return 0
+ }
+
+ prefix = value.split(ampersand, 2).join(ampersand)
+
+ return prefix.length - decode(prefix).length
+}