Add _.toLower and _.toUpper.

This commit is contained in:
John-David Dalton
2015-10-08 21:50:30 -07:00
parent d9fc0f1e37
commit 150bd32f97
2 changed files with 56 additions and 6 deletions

View File

@@ -11120,7 +11120,7 @@
}); });
/** /**
* Converts `string` to lower case. * Converts `string`, as space separated words, to lower case.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -11129,13 +11129,13 @@
* @returns {string} Returns the lower cased string. * @returns {string} Returns the lower cased string.
* @example * @example
* *
* _.lowerCase('Foo Bar'); * _.lowerCase('--Foo-Bar');
* // => 'foo bar' * // => 'foo bar'
* *
* _.lowerCase('fooBar'); * _.lowerCase('fooBar');
* // => 'foo bar' * // => 'foo bar'
* *
* _.lowerCase('__foo_bar__'); * _.lowerCase('__FOO_BAR__');
* // => 'foo bar' * // => 'foo bar'
*/ */
var lowerCase = createCompounder(function(result, word, index) { var lowerCase = createCompounder(function(result, word, index) {
@@ -11584,6 +11584,52 @@
return result; return result;
} }
/**
* Converts `string`, as a whole, to lower case.
*
* @static
* @memberOf _
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the lower cased string.
* @example
*
* _.toLower('--Foo-Bar');
* // => '--foo-bar'
*
* _.toLower('fooBar');
* // => 'foobar'
*
* _.toLower('__FOO_BAR__');
* // => '__foo_bar__'
*/
function toLower(value) {
return toString(value).toLowerCase();
}
/**
* Converts `string`, as a whole, to upper case.
*
* @static
* @memberOf _
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the upper cased string.
* @example
*
* _.toUpper('--foo-bar');
* // => '--FOO-BAR'
*
* _.toUpper('fooBar');
* // => 'FOOBAR'
*
* _.toUpper('__foo_bar__');
* // => '__FOO_BAR__'
*/
function toUpper(value) {
return toString(value).toUpperCase();
}
/** /**
* Removes leading and trailing whitespace or specified characters from `string`. * Removes leading and trailing whitespace or specified characters from `string`.
* *
@@ -11809,7 +11855,7 @@
} }
/** /**
* Converts `string` to upper case. * Converts `string`, as space separated words, to upper case.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -11818,7 +11864,7 @@
* @returns {string} Returns the upper cased string. * @returns {string} Returns the upper cased string.
* @example * @example
* *
* _.upperCase('Foo Bar'); * _.upperCase('--foo-bar');
* // => 'FOO BAR' * // => 'FOO BAR'
* *
* _.upperCase('fooBar'); * _.upperCase('fooBar');
@@ -12904,7 +12950,9 @@
lodash.sumBy = sumBy; lodash.sumBy = sumBy;
lodash.template = template; lodash.template = template;
lodash.toInteger = toInteger; lodash.toInteger = toInteger;
lodash.toLower = toLower;
lodash.toString = toString; lodash.toString = toString;
lodash.toUpper = toUpper;
lodash.trim = trim; lodash.trim = trim;
lodash.trimLeft = trimLeft; lodash.trimLeft = trimLeft;
lodash.trimRight = trimRight; lodash.trimRight = trimRight;

View File

@@ -20991,7 +20991,9 @@
'some', 'some',
'startsWith', 'startsWith',
'toInteger', 'toInteger',
'toLower',
'toString', 'toString',
'toUpper',
'trim', 'trim',
'trimLeft', 'trimLeft',
'trimRight', 'trimRight',
@@ -21236,7 +21238,7 @@
var acceptFalsey = _.difference(allMethods, rejectFalsey); var acceptFalsey = _.difference(allMethods, rejectFalsey);
QUnit.test('should accept falsey arguments', function(assert) { QUnit.test('should accept falsey arguments', function(assert) {
assert.expect(253); assert.expect(255);
var emptyArrays = _.map(falsey, _.constant([])); var emptyArrays = _.map(falsey, _.constant([]));