Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Transform camelCase to ACTION_NAMES
function transformToActionNames(actions) {
return _.map(actions, (action) => {
let newActionName = ''
for (var index = 0; index < action.length; index++) {
var char = action[index]
if (index === 0) {
newActionName += char.toUpperCase()
continue
}
if (char == char.toUpperCase()) {
newActionName += '_' + char
continue
}
newActionName += char.toUpperCase()
}
return newActionName
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.