source: frontend/node_modules/@svgr/hast-util-to-babel-ast/lib/util.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[9af201e]1"use strict";
2
3exports.__esModule = true;
4exports.isNumeric = isNumeric;
5exports.hyphenToCamelCase = hyphenToCamelCase;
6exports.trimEnd = trimEnd;
7exports.kebabCase = kebabCase;
8exports.replaceSpaces = replaceSpaces;
9
10/**
11 * Determines if the specified string consists entirely of numeric characters.
12 *
13 * @param {*} [value]
14 * @returns {boolean}
15 */
16function 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
27function 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
40function trimEnd(haystack, needle) {
41 return haystack.endsWith(needle) ? haystack.slice(0, -needle.length) : haystack;
42}
43
44const KEBAB_REGEX = /[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g;
45
46function kebabCase(str) {
47 return str.replace(KEBAB_REGEX, match => `-${match.toLowerCase()}`);
48}
49
50const SPACES_REGEXP = /[\t\r\n\u0085\u2028\u2029]+/g;
51
52function replaceSpaces(str) {
53 return str.replace(SPACES_REGEXP, ' ');
54}
Note: See TracBrowser for help on using the repository browser.