| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | exports.__esModule = true;
|
|---|
| 4 | exports.isNumeric = isNumeric;
|
|---|
| 5 | exports.hyphenToCamelCase = hyphenToCamelCase;
|
|---|
| 6 | exports.trimEnd = trimEnd;
|
|---|
| 7 | exports.kebabCase = kebabCase;
|
|---|
| 8 | exports.replaceSpaces = replaceSpaces;
|
|---|
| 9 |
|
|---|
| 10 | /**
|
|---|
| 11 | * Determines if the specified string consists entirely of numeric characters.
|
|---|
| 12 | *
|
|---|
| 13 | * @param {*} [value]
|
|---|
| 14 | * @returns {boolean}
|
|---|
| 15 | */
|
|---|
| 16 | function isNumeric(value) {
|
|---|
| 17 | return !Number.isNaN(value - parseFloat(value));
|
|---|
| 18 | }
|
|---|
| 19 | /**
|
|---|
| 20 | * Convert a hyphenated string to camelCase.
|
|---|
| 21 | *
|
|---|
| 22 | * @param {string} string
|
|---|
| 23 | * @returns {string}
|
|---|
| 24 | */
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | function hyphenToCamelCase(string) {
|
|---|
| 28 | return string.replace(/-(.)/g, (match, chr) => chr.toUpperCase());
|
|---|
| 29 | }
|
|---|
| 30 | /**
|
|---|
| 31 | * Trim the specified substring off the string. If the string does not end
|
|---|
| 32 | * with the specified substring, this is a no-op.
|
|---|
| 33 | *
|
|---|
| 34 | * @param {string} haystack String to search in
|
|---|
| 35 | * @param {string} needle String to search for
|
|---|
| 36 | * @return {string}
|
|---|
| 37 | */
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | function trimEnd(haystack, needle) {
|
|---|
| 41 | return haystack.endsWith(needle) ? haystack.slice(0, -needle.length) : haystack;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | const KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
|
|---|
| 45 |
|
|---|
| 46 | function kebabCase(str) {
|
|---|
| 47 | return str.replace(KEBAB_REGEX, match => `-${match.toLowerCase()}`);
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | const SPACES_REGEXP = /[\t\r\n\u0085\u2028\u2029]+/g;
|
|---|
| 51 |
|
|---|
| 52 | function replaceSpaces(str) {
|
|---|
| 53 | return str.replace(SPACES_REGEXP, ' ');
|
|---|
| 54 | } |
|---|