INNER CODE UNIT · TypeScript

hasKey

beeequeue/yuna · src/utils/index.ts:141

export const hasKey = (obj: any, value: any) => Object.keys(obj).includes(value)

export const clamp = (x: number, min: number, max: number) =>
  Math.max(min, Math.min(x, max))

export const enumToArray = <E>(Enum: E): E[] => Object.values(Enum)

export const enumKeysToArray = <E>(Enum: E): Array<keyof E> => Object.keys(Enum) as any

export const capitalize = (str: string) => {
  let words = str.split(" ")

  words = words.map((word) => {
    const first = word.slice(0, 1).toUpperCase()
    return first + word.slice(1).toLowerCase()
  })

  return words.join(" ")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…