by arsome · 5y ago · 0 comments
EDIT: After doing a bit of research I found "tstl", looks interesting, their hashmap appears to support custom hashers and equality comparisons:
https://tstl.dev/api/classes/std.hashmap.html
I'm curious about experiences with it if anyone's had the chance?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
const returnCache = new Map<() => any, any>()
const memoized = <T extends () => any>(f: T): ReturnType<T> => {
if (returnCache.has(f)) return returnCache.get(f)
const v = f()
returnCache.set(f, v)
return v
}With a Map, you can easily and efficiently associate data with DOM nodes without changing them.