stuff done
This commit is contained in:
38
lib/utils.ts
38
lib/utils.ts
@@ -3,6 +3,7 @@ import bcrypt from 'bcryptjs'
|
||||
import {type ClassValue, clsx} from 'clsx'
|
||||
import {getLocale} from 'next-intl/server'
|
||||
import slugify from 'slugify'
|
||||
import striptags from 'striptags'
|
||||
import {twMerge} from 'tailwind-merge'
|
||||
|
||||
import {i18nDefaultLocale} from '@/i18n-config'
|
||||
@@ -157,3 +158,40 @@ export const dbErrorHandling = (e: unknown, message?: string | null) => {
|
||||
*/
|
||||
export const isEmptyObj = (obj: object): boolean =>
|
||||
Object.keys(obj).length === 0
|
||||
|
||||
/**
|
||||
* To convert letter on typing from latin to cyr
|
||||
* TODO: need to complete
|
||||
*
|
||||
* @param term
|
||||
*/
|
||||
export const replacerLat2Cyr = (term: string): string => {
|
||||
const obj = {g: 'п', e: 'у', o: 'щ', f: 'а'}
|
||||
|
||||
return term
|
||||
.split('')
|
||||
.map((ch: PropertyKey): string => {
|
||||
return obj.hasOwnProperty(ch as PropertyKey)
|
||||
? (obj[ch as never] as string)
|
||||
: (ch as string)
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
|
||||
type NormalizeConfigType =
|
||||
| {
|
||||
stripTags?: boolean
|
||||
}
|
||||
| undefined
|
||||
| null
|
||||
|
||||
export function normalizeData(
|
||||
data: string | null,
|
||||
config?: NormalizeConfigType
|
||||
): string {
|
||||
if (config?.stripTags) {
|
||||
data = striptags(data as string)
|
||||
}
|
||||
|
||||
return data as string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user