UNPKG

1.96 kBSource Map (JSON)View Raw
1{"version":3,"file":null,"sources":["../src/utils.js"],"sourcesContent":["function merge(obj) {\n let i = 1\n let target\n let key\n\n for (; i < arguments.length; i++) {\n target = arguments[i]\n for (key in target) {\n if (Object.prototype.hasOwnProperty.call(target, key)) {\n obj[key] = target[key]\n }\n }\n }\n\n return obj\n}\n\nfunction noop() {}\nnoop.exec = noop\n\nfunction escape(html, encode) {\n return html\n .replace(encode ? /&/g : /&(?!#?\\w+;)/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n}\n\nfunction unescape(html) {\n\t// explicitly match decimal, hex, and named HTML entities\n return html.replace(/&(#(?:\\d+)|(?:#x[0-9A-Fa-f]+)|(?:\\w+));?/g, (_, n) => {\n n = n.toLowerCase()\n if (n === 'colon') return ':'\n if (n.charAt(0) === '#') {\n return n.charAt(1) === 'x' ?\n String.fromCharCode(parseInt(n.substring(2), 16)) :\n String.fromCharCode(Number(n.substring(1)))\n }\n return ''\n })\n}\n\nfunction replace(regex, opt) {\n regex = regex.source\n opt = opt || ''\n return function self(name, val) {\n if (!name) return new RegExp(regex, opt)\n val = val.source || val\n val = val.replace(/(^|[^\\[])\\^/g, '$1')\n regex = regex.replace(name, val)\n return self\n }\n}\n\nfunction slugify(input) {\n return input\n // remove html tags\n .replace(/<(?:.|\\n)*?>/gm, '')\n .replace(/[!\\\"#$%&'\\(\\)\\*\\+,\\/:;<=>\\?\\@\\[\\\\\\]\\^`\\{\\|\\}~]/g, '') // eslint-disable-line no-useless-escape\n // Replace dots and spaces with a sepeator\n .replace(/(\\s|\\.)/g, '-')\n // Convert 2 or more sepeators into just one sepeator\n .replace(/-{2,}/g, '-')\n // Make the whole thing lowercase\n .toLowerCase()\n}\n\nexport {\n merge,\n noop,\n escape,\n unescape,\n replace,\n slugify\n}\n"],"names":[],"mappings":"kLAAA"}
\No newline at end of file