From 906bdb793debaac79d9dea1ccbe9817f064a38cd Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 30 Dec 2017 18:19:26 +0000 Subject: [PATCH] Travis build: 677 [ci skip] --- README.md | 11 +++++------ docs/index.html | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1ab0c8c3c..c8317e4a3 100644 --- a/README.md +++ b/README.md @@ -3635,13 +3635,12 @@ Break the string into words and combine them using `_` as a separator. For more detailed explanation of this Regex, [visit this Site](https://regex101.com/r/bMCgAB/1). ```js -const toSnakeCase = str => { +const toSnakeCase = str => str && - str - .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) - .map(x => x.toLowerCase()) - .join('_'); -}; + str + .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) + .map(x => x.toLowerCase()) + .join('_'); ```
diff --git a/docs/index.html b/docs/index.html index e4346b4ec..22500c832 100644 --- a/docs/index.html +++ b/docs/index.html @@ -731,13 +731,12 @@ toKebabCase('some text'); // 'some-text' toKebabCase('some-mixed_string With spaces_underscores-and-hyphens'); // 'some-mixed-string-with-spaces-underscores-and-hyphens' toKebabCase('AllThe-small Things'); // "all-the-small-things" toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); // "i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-xml-and-html" -

toSnakeCase

Converts a string to snake case.

Break the string into words and combine them using _ as a separator. For more detailed explanation of this Regex, visit this Site.

const toSnakeCase = str => {
+

toSnakeCase

Converts a string to snake case.

Break the string into words and combine them using _ as a separator. For more detailed explanation of this Regex, visit this Site.

const toSnakeCase = str =>
   str &&
-    str
-      .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
-      .map(x => x.toLowerCase())
-      .join('_');
-};
+  str
+    .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
+    .map(x => x.toLowerCase())
+    .join('_');
 
toSnakeCase('camelCase'); // 'camel_case'
 toSnakeCase('some text'); // 'some_text'
 toSnakeCase('some-javascript-property'); // 'some_javascript_property'