Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "swap-case", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Swap the case of a string", | ||
"main": "swap-case.js", | ||
"files": [ | ||
"swap-case.js", | ||
"LICENSE" | ||
], | ||
"scripts": { | ||
@@ -31,4 +35,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": { | ||
"lower-case": "^1.1.1", | ||
"upper-case": "^1.1.1" | ||
} | ||
} |
@@ -6,6 +6,7 @@ # Swap Case | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
Swap the case of a string with non-ASCII character support. Also handles non-string entities, such as objects with a `toString` property, numbers and booleans. Empty values (`null` and `undefined`) will come out as an empty string. | ||
Swap the case of 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 | ||
@@ -26,2 +27,4 @@ | ||
swapCase('Iñtërnâtiônàlizætiøn'); //=> "iÑTËRNÂTIÔNÀLIZÆTIØN" | ||
swapCase('My String', 'tr'); //=> "mY sTRİNG" | ||
``` | ||
@@ -39,3 +42,1 @@ | ||
[coveralls-url]: https://coveralls.io/r/blakeembrey/swap-case?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/blakeembrey.svg?style=flat | ||
[gittip-url]: https://www.gittip.com/blakeembrey |
@@ -0,1 +1,4 @@ | ||
var upperCase = require('upper-case'); | ||
var lowerCase = require('lower-case'); | ||
/** | ||
@@ -6,5 +9,6 @@ * Swap the case of a string. Manually iterate over every character and check | ||
* @param {String} str | ||
* @param {String} [locale] | ||
* @return {String} | ||
*/ | ||
module.exports = function (str) { | ||
module.exports = function (str, locale) { | ||
if (str == null) { | ||
@@ -18,5 +22,5 @@ return ''; | ||
var c = str[i]; | ||
var u = c.toUpperCase(); | ||
var u = upperCase(c, locale); | ||
result += u === c ? c.toLowerCase() : u; | ||
result += u === c ? lowerCase(c, locale) : u; | ||
} | ||
@@ -23,0 +27,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40
3764
2
3
4
22
+ Addedlower-case@^1.1.1
+ Addedupper-case@^1.1.1
+ Addedlower-case@1.1.4(transitive)
+ Addedupper-case@1.1.3(transitive)