change-case
Advanced tools
Comparing version 0.0.1 to 0.0.2
16
index.js
@@ -10,2 +10,4 @@ var acceptString = function (fn) { | ||
var insignificant = exports.insignificantWords = ['and']; | ||
var lowerCase = exports.lowerCase = exports.lower = acceptString(function (str) { | ||
@@ -25,4 +27,3 @@ return str.toLowerCase(); | ||
return splitWords(str).map(function (word) { | ||
word = lowerCase(word); | ||
if (!isSignificant && (word.length < 3 || ~['and'].indexOf(word))) { | ||
if (!isSignificant && (word.length < 3 || ~insignificant.indexOf(word))) { | ||
return word; | ||
@@ -62,1 +63,12 @@ } | ||
}); | ||
exports.switchCase = exports.switch = acceptString(function (str) { | ||
var char; | ||
for (var i = 0; i < str.length; i++) { | ||
char = str.charAt(i); | ||
str = str.substr(0, i) + (char === upperCase(char) ? lowerCase(char) : upperCase(char)) + str.substr(i + 1); | ||
} | ||
return str; | ||
}); |
{ | ||
"name": "change-case", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Convert strings between camelCase, PascalCase, Title Case, snake_case, etc", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,11 +17,12 @@ # Change Case | ||
* `changeCase.upperCase(string)` | ||
* `changeCase.lowerCase(string)` | ||
* `changeCase.titleCase(string [, ignoreInsignificantWords])` | ||
* `changeCase.camelCase(string)` | ||
* `changeCase.snakeCase(string)` | ||
* `changeCase.paramCase(string)` | ||
* `changeCase.dotCase(string)` | ||
* `changeCase.pathCase(string)` | ||
* `changeCase.constantCase(string)` | ||
* changeCase.upperCase(string) | ||
* changeCase.lowerCase(string) | ||
* changeCase.titleCase(string [, ignoreInsignificantWords]) | ||
* changeCase.camelCase(string) | ||
* changeCase.snakeCase(string) | ||
* changeCase.paramCase(string) | ||
* changeCase.dotCase(string) | ||
* changeCase.pathCase(string) | ||
* changeCase.constantCase(string) | ||
* changeCase.switchCase(string) | ||
@@ -39,2 +40,3 @@ ```javascript | ||
changeCase.constantCase('test string') // "TEST_STRING" | ||
changeCase.switchCase('TeST stRInG') // "tEst STriNg" | ||
``` | ||
@@ -41,0 +43,0 @@ |
@@ -68,2 +68,7 @@ /* global describe, it */ | ||
}); | ||
it('should switch the cases', function () { | ||
assert.equal(changeCase.switchCase('RaNdOMcasE'), 'rAnDomCASe'); | ||
assert.equal(changeCase.switchCase('mIX It.Down?'), 'Mix iT.dOWN?'); | ||
}); | ||
}); |
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
7627
118
45