* fix memory leak * add optional condition to hasAtRule * use known tree to handle `@apply` when required `@tailwind` at rules exists Otherwise we will generate the lookup tree. * only generate the missing `@tailwind` atrules when using `@apply` * update perf config to reflect 2.0 changes * update changelog * ensure lookup tree is correctly cached based on used tailwind atrules
25 lines
412 B
JavaScript
25 lines
412 B
JavaScript
import { shared } from './disposables'
|
|
|
|
export function useMemo(cb, keyResolver) {
|
|
let cache = new Map()
|
|
|
|
function clearCache() {
|
|
cache.clear()
|
|
shared.add(clearCache)
|
|
}
|
|
|
|
shared.add(clearCache)
|
|
|
|
return (...args) => {
|
|
let key = keyResolver(...args)
|
|
|
|
if (cache.has(key)) {
|
|
return cache.get(key)
|
|
}
|
|
|
|
let result = cb(...args)
|
|
cache.set(key, result)
|
|
|
|
return result
|
|
}
|
|
}
|