node_modules.swap-case.swap-case.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-client-maven-plugin Show documentation
Show all versions of apollo-client-maven-plugin Show documentation
Maven plugin for generating graphql clients
The newest version!
var upperCase = require('upper-case')
var lowerCase = require('lower-case')
/**
* Swap the case of a string. Manually iterate over every character and check
* instead of replacing certain characters for better unicode support.
*
* @param {String} str
* @param {String} [locale]
* @return {String}
*/
module.exports = function (str, locale) {
if (str == null) {
return ''
}
var result = ''
for (var i = 0; i < str.length; i++) {
var c = str[i]
var u = upperCase(c, locale)
result += u === c ? lowerCase(c, locale) : u
}
return result
}