Home

tailwind-ctp-intellisense @4be5d9d0820980016ea45c5ee8d17a6846ea1e43 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-language-service / src / util / lazy.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
// https://www.codementor.io/@agustinchiappeberrini/lazy-evaluation-and-javascript-a5m7g8gs3

export interface Lazy<T> {
  (): T
  isLazy: boolean
}

export const lazy = <T>(getter: () => T): Lazy<T> => {
  let evaluated: boolean = false
  let _res: T = null
  const res = <Lazy<T>>function (): T {
    if (evaluated) return _res
    _res = getter.apply(this, arguments)
    evaluated = true
    return _res
  }
  res.isLazy = true
  return res
}