mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2025-01-14 21:07:26 -08:00
74eb5fa045
- `example/proxy` is new folder for `example_proxy`. - `riven` is new folder for the main riven lib. - Updated metadata to be an array and include HTTP method.
27 lines
577 B
JavaScript
27 lines
577 B
JavaScript
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
|
|
}
|