News for hackers. Stuff that matters.
Re:An efficient way to make hash maps with insertion ordering by upzylon on Thursday July 01, 2021 @01:29PM (#27701795)
There definitely are valid use cases for a Map, and even more now that we have WeakMaps (e.g. associating data DOM nodes). Or mapping functions to values, e.g. something like this:

  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
  }

There are no comments on this comment yet.