2021-01-21 12:30:53 +01:00
|
|
|
const ALPHA_NUMERIC_REGEX = /^[A-Za-z0-9]+$/g
|
|
|
|
|
2021-01-21 13:08:57 +01:00
|
|
|
module.exports.FIND_HBS_REGEX = /{{([^{}])+}}/g
|
2021-01-21 12:30:53 +01:00
|
|
|
|
2021-01-21 12:32:26 +01:00
|
|
|
module.exports.isAlphaNumeric = char => {
|
2021-01-21 12:30:53 +01:00
|
|
|
return char.match(ALPHA_NUMERIC_REGEX)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.swapStrings = (string, start, length, swap) => {
|
|
|
|
return string.slice(0, start) + swap + string.slice(start + length)
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:48:23 +01:00
|
|
|
// removes null and undefined
|
|
|
|
module.exports.removeNull = obj => {
|
|
|
|
return Object.fromEntries(
|
|
|
|
Object.entries(obj)
|
2021-01-21 19:08:04 +01:00
|
|
|
.filter(entry => entry[1] != null)
|
2021-01-21 14:48:23 +01:00
|
|
|
.map(([key, value]) => [
|
|
|
|
key,
|
|
|
|
value === Object(value) ? module.exports.removeNull(value) : value,
|
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|