Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: node_modules/vulcanize/node_modules/whacko/lib/utils.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/whacko/lib/utils.js
diff --git a/node_modules/vulcanize/node_modules/whacko/lib/utils.js b/node_modules/vulcanize/node_modules/whacko/lib/utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..5717677c7a840949c230eb915d26959d7da7ba71
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/whacko/lib/utils.js
@@ -0,0 +1,51 @@
+/**
+ * HTML Tags
+ */
+
+var tags = { tag: true, script: true, style: true };
+
+/**
+ * Check if the DOM element is a tag
+ *
+ * isTag(type) includes <script> and <style> tags
+ */
+
+exports.isTag = function(type) {
+ if (type.type) type = type.type;
+ return tags[type] || false;
+};
+
+/**
+ * Convert a string to camel case notation.
+ * @param {String} str String to be converted.
+ * @return {String} String in camel case notation.
+ */
+
+exports.camelCase = function(str) {
+ return str.replace(/[_.-](\w|$)/g, function(_, x) {
+ return x.toUpperCase();
+ });
+};
+
+/**
+ * Convert a string from camel case to "CSS case", where word boundaries are
+ * described by hyphens ("-") and all characters are lower-case.
+ * @param {String} str String to be converted.
+ * @return {string} String in "CSS case".
+ */
+exports.cssCase = function(str) {
+ return str.replace(/[A-Z]/g, '-$&').toLowerCase();
+};
+
+/**
+ * Iterate over each DOM element without creating intermediary Cheerio instances.
+ *
+ * This is indented for use internally to avoid otherwise unnecessary memory pressure introduced
+ * by _make.
+ */
+
+exports.domEach = function(cheerio, fn) {
+ var i = 0, len = cheerio.length;
+ while (i < len && fn(i, cheerio[i]) !== false) ++i;
+ return cheerio;
+};

Powered by Google App Engine
This is Rietveld 408576698