Travis build: 215
This commit is contained in:
@ -208,6 +208,7 @@
|
||||
<a class="sublink-1" href="#sortcharactersinstring">sortCharactersInString</a>
|
||||
<a class="sublink-1" href="#tocamelcase">toCamelCase</a>
|
||||
<a class="sublink-1" href="#tokebabcase">toKebabCase</a>
|
||||
<a class="sublink-1" href="#tosnakecase">toSnakeCase</a>
|
||||
<a class="sublink-1" href="#truncatestring">truncateString</a>
|
||||
<a class="sublink-1" href="#words">words</a>
|
||||
|
||||
@ -1291,6 +1292,16 @@ Also check if a string starts with a hyphen and remove it if yes.</p>
|
||||
// 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"
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="tosnakecase">toSnakeCase</h3></div><div class="section double-padded">
|
||||
<p>Converts a string to snakecase.</p>
|
||||
<p>Use <code>replace()</code> to add underscores before capital letters, convert <code>toLowerCase()</code>, then <code>replace()</code> hyphens and spaces with underscores.</p>
|
||||
<pre><code class="language-js">const toSnakeCase = str =>
|
||||
str.replace(/(\w)([A-Z])/g, '$1_$2').replace(/[\s-_]+/g, '_').toLowerCase();
|
||||
// toSnakeCase("camelCase") -> 'camel_case'
|
||||
// toSnakeCase("some text") -> 'some_text'
|
||||
// toSnakeCase("some-javascript-property") -> 'some_javascript_property'
|
||||
// toSnakeCase("some-mixed_string With spaces_underscores-and-hyphens") -> 'some_mixed_string_with_spaces_underscores_and_hyphens'
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="truncatestring">truncateString</h3></div><div class="section double-padded">
|
||||
<p>Truncates a string up to a specified length.</p>
|
||||
<p>Determine if the string's <code>length</code> is greater than <code>num</code>.
|
||||
|
||||
Reference in New Issue
Block a user