Created
June 16, 2022 07:12
-
-
Save fsjorgeluis/55c4bfa67148034f867155516b319638 to your computer and use it in GitHub Desktop.
aws cdk layer: key-formatter helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.keyFormatter = (key, value) => { | |
const formattedKey = `${key}#${value.replace(/\s/g, '').toUpperCase()}`; | |
return formattedKey.toUpperCase(); | |
}; | |
module.exports.wordNormalizer = (word) => { | |
return word.toLowerCase().replace(/\b\w/g, (firstChar) => firstChar.toUpperCase()) | |
}; | |
module.exports.capitalize = (phrase) => { | |
return phrase | |
.split(' ') | |
.map((word) => word.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase())) | |
.join(' '); | |
} | |
module.exports.keyFit = (word) => { | |
return word.replace(/\b\w/g, (firstChar) => firstChar.toUpperCase()); | |
} | |
module.exports.objectCleaner = (obj) => { | |
return Object.entries(obj) | |
.filter(([key, value]) => value != '') | |
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment