Skip to content

Commit

Permalink
Add String#uncapitalize util
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jun 10, 2015
1 parent 5b63ee0 commit 12ee4b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion string/#/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ module.exports = {
plainReplace: require('./plain-replace'),
plainReplaceAll: require('./plain-replace-all'),
repeat: require('./repeat'),
startsWith: require('./starts-with')
startsWith: require('./starts-with'),
uncapitalize: require('./uncapitalize')
};
8 changes: 8 additions & 0 deletions string/#/uncapitalize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var ensureStringifiable = require('../../object/validate-stringifiable-value');

module.exports = function () {
var str = ensureStringifiable(this);
return str.charAt(0).toLowerCase() + str.slice(1);
};
10 changes: 10 additions & 0 deletions test/string/#/uncapitalize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

module.exports = function (t, a) {
a(t.call('raz'), 'raz', "Word");
a(t.call('BLA'), 'bLA', "Uppercase");
a(t.call(''), '', "Empty");
a(t.call('a'), 'a', "One letter");
a(t.call('this is a test'), 'this is a test', "Sentence");
a(t.call('This is a test'), 'this is a test', "Capitalized sentence");
};

0 comments on commit 12ee4b8

Please sign in to comment.