title-case
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "title-case", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Title case a string", | ||
"main": "title-case.js", | ||
"files": [ | ||
"title-case.js", | ||
"LICENSE" | ||
], | ||
"scripts": { | ||
@@ -29,8 +33,9 @@ "test": "istanbul cover _mocha -- -R spec" | ||
"istanbul": "^0.3.0", | ||
"mocha": "^1.18.2" | ||
"mocha": "^1.18.2", | ||
"pre-commit": "0.0.9" | ||
}, | ||
"dependencies": { | ||
"sentence-case": "^1.0.2", | ||
"upper-case": "^1.0.0" | ||
"sentence-case": "^1.1.1", | ||
"upper-case": "^1.0.3" | ||
} | ||
} |
@@ -6,6 +6,7 @@ # Title Case | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
Title case a string. | ||
Supports Unicode (non-ASCII characters) and non-string entities, such as objects with a `toString` property, numbers and booleans. Empty values (`null` and `undefined`) will result in an empty string. | ||
## Installation | ||
@@ -24,2 +25,4 @@ | ||
titleCase('PascalCase'); //=> "Pascal Case" | ||
titleCase('STRING', 'tr'); //=> "Strıng" | ||
``` | ||
@@ -37,3 +40,1 @@ | ||
[coveralls-url]: https://coveralls.io/r/blakeembrey/title-case?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/blakeembrey.svg?style=flat | ||
[gittip-url]: https://www.gittip.com/blakeembrey |
@@ -1,3 +0,3 @@ | ||
var upper = require('upper-case'); | ||
var sentence = require('sentence-case'); | ||
var upperCase = require('upper-case'); | ||
var sentenceCase = require('sentence-case'); | ||
@@ -8,6 +8,9 @@ /** | ||
* @param {String} string | ||
* @param {String} [locale] | ||
* @return {String} | ||
*/ | ||
module.exports = function (string) { | ||
return sentence(string).replace(/^\w| \w/g, upper); | ||
module.exports = function (str, locale) { | ||
return sentenceCase(str, locale).replace(/^.| ./g, function (m) { | ||
return upperCase(m, locale); | ||
}); | ||
}; |
38
3368
3
4
14
Updatedsentence-case@^1.1.1
Updatedupper-case@^1.0.3