|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
638 bytes
|
| Line | |
|---|
| 1 | var createCompounder = require('./_createCompounder');
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Converts `string` to
|
|---|
| 5 | * [snake case](https://en.wikipedia.org/wiki/Snake_case).
|
|---|
| 6 | *
|
|---|
| 7 | * @static
|
|---|
| 8 | * @memberOf _
|
|---|
| 9 | * @since 3.0.0
|
|---|
| 10 | * @category String
|
|---|
| 11 | * @param {string} [string=''] The string to convert.
|
|---|
| 12 | * @returns {string} Returns the snake cased string.
|
|---|
| 13 | * @example
|
|---|
| 14 | *
|
|---|
| 15 | * _.snakeCase('Foo Bar');
|
|---|
| 16 | * // => 'foo_bar'
|
|---|
| 17 | *
|
|---|
| 18 | * _.snakeCase('fooBar');
|
|---|
| 19 | * // => 'foo_bar'
|
|---|
| 20 | *
|
|---|
| 21 | * _.snakeCase('--FOO-BAR--');
|
|---|
| 22 | * // => 'foo_bar'
|
|---|
| 23 | */
|
|---|
| 24 | var snakeCase = createCompounder(function(result, word, index) {
|
|---|
| 25 | return result + (index ? '_' : '') + word.toLowerCase();
|
|---|
| 26 | });
|
|---|
| 27 |
|
|---|
| 28 | module.exports = snakeCase;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.