From c5ca1393b8628e658bf36bb6cee6931fa6b914f1 Mon Sep 17 00:00:00 2001 From: Rohit Date: Sat, 23 Dec 2017 08:52:08 +0530 Subject: [PATCH] remove toKebabCase --- snippets/toKebabCase.md | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 snippets/toKebabCase.md diff --git a/snippets/toKebabCase.md b/snippets/toKebabCase.md deleted file mode 100644 index 9d5432325..000000000 --- a/snippets/toKebabCase.md +++ /dev/null @@ -1,17 +0,0 @@ -### toKebabCase - -Converts a string to snakecase. -Use `replace()` to add spaces before capital letters, convert `toLowerCase()`, then `replace()` and undesrsocres and spaces with hyphens. -Also check if a string starts with hyphen and if yes remove it. - -```js -const toKebabCase = str => { - str = str.replace(/([A-Z])/g," $1").toLowerCase().replace(/_/g,' ').replace(/\s\s+/g, '-').replace(/\s/g,'-'); - return str.startsWith('-') ? str.slice(1,str.length) : str; -} -// toKebabCase("camelCase") -> 'camel-case' -// toKebabCase("some text") -> 'some-text' -// toKebabCase("some-javascript-property") -> 'some-javascript-property' -// 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" -```