chore: refactoring

This commit is contained in:
Cory Dransfeldt 2024-10-08 17:35:26 -07:00
parent df5fddefc0
commit e0593447eb
No known key found for this signature in database
40 changed files with 181 additions and 232 deletions

View file

@ -1,5 +1,3 @@
import slugify from 'slugify'
export const shuffleArray = array => {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1))
@ -10,17 +8,6 @@ export const shuffleArray = array => {
return array
}
export const sanitizeMediaString = (str) => {
if (!str) return null
const sanitizedString = str.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '')
return slugify(sanitizedString, {
replacement: '-',
remove: /[#,&,+()$~%.'":*?<>{}]/g,
lower: true,
})
}
export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
export const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()