sadgod
Version:
SadGod helps you extract data from ROTMG's internal SWF files. Currently it allows you to read the names and values of all binary packet ids used in the network communication. This is helpful because the game often changes the packet ids.
14 lines (11 loc) • 598 B
JavaScript
const hasLetters = /[a-z]/i
function fixPropertyCasing(parameter) {
while (parameter.endsWith('_')) parameter = parameter.substring(0, parameter.length - 1)
if (hasLetters.test(parameter) && parameter === parameter.toUpperCase() && !parameter.includes('_')) return parameter.toLowerCase()
if (!parameter.includes('_')) return parameter
return parameter.split('_').map((section, index) => {
if (index < 1) return section.toLowerCase()
return section.substring(0, 1).toUpperCase() + section.substring(1).toLowerCase()
}).join('')
}
module.exports = fixPropertyCasing