Comparing version 1.0.0 to 1.0.1
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple case detection and conversion for strings.", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
1.0.1 - May 27, 2015 | ||
-------------------- | ||
* fix `inverse` case, with tests | ||
1.0.0 - March 9, 2014 | ||
@@ -3,0 +7,0 @@ --------------------- |
@@ -106,9 +106,10 @@ | ||
exports.inverse = function (string) { | ||
for (var i = 0, char; char = string[i]; i++) { | ||
var chars = string.split(''); | ||
for (var i = 0, char; char = chars[i]; i++) { | ||
if (!/[a-z]/i.test(char)) continue; | ||
var upper = char.toUpperCase(); | ||
var lower = char.toLowerCase(); | ||
string[i] = char == upper ? lower : upper; | ||
chars[i] = char == upper ? lower : upper; | ||
} | ||
return string; | ||
return chars.join(''); | ||
}; | ||
@@ -115,0 +116,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple case conversion and detection for strings.", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
@@ -50,2 +50,8 @@ describe('case', function () { | ||
describe('#inverse', function () { | ||
it('should invert case', function () { | ||
assert('tHIS iS A sTRING' == kase.inverse('This Is a String')); | ||
}); | ||
}); | ||
}); |
123440
4777