|
|
"use strict"; |
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
|
exports.isCheerio = isCheerio; |
|
|
exports.camelCase = camelCase; |
|
|
exports.cssCase = cssCase; |
|
|
exports.domEach = domEach; |
|
|
exports.isHtml = isHtml; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isCheerio(maybeCheerio) { |
|
|
return maybeCheerio.cheerio != null; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function camelCase(str) { |
|
|
return str.replace(/[._-](\w|$)/g, (_, x) => x.toUpperCase()); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function cssCase(str) { |
|
|
return str.replace(/[A-Z]/g, '-$&').toLowerCase(); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function domEach(array, fn) { |
|
|
const len = array.length; |
|
|
for (let i = 0; i < len; i++) |
|
|
fn(array[i], i); |
|
|
return array; |
|
|
} |
|
|
var CharacterCode; |
|
|
(function (CharacterCode) { |
|
|
CharacterCode[CharacterCode["LowerA"] = 97] = "LowerA"; |
|
|
CharacterCode[CharacterCode["LowerZ"] = 122] = "LowerZ"; |
|
|
CharacterCode[CharacterCode["UpperA"] = 65] = "UpperA"; |
|
|
CharacterCode[CharacterCode["UpperZ"] = 90] = "UpperZ"; |
|
|
CharacterCode[CharacterCode["Exclamation"] = 33] = "Exclamation"; |
|
|
})(CharacterCode || (CharacterCode = {})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isHtml(str) { |
|
|
const tagStart = str.indexOf('<'); |
|
|
if (tagStart === -1 || tagStart > str.length - 3) |
|
|
return false; |
|
|
const tagChar = str.charCodeAt(tagStart + 1); |
|
|
return (((tagChar >= CharacterCode.LowerA && tagChar <= CharacterCode.LowerZ) || |
|
|
(tagChar >= CharacterCode.UpperA && tagChar <= CharacterCode.UpperZ) || |
|
|
tagChar === CharacterCode.Exclamation) && |
|
|
str.includes('>', tagStart + 2)); |
|
|
} |
|
|
|