aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/memoize.ts
blob: aa20e7d737daa4d1fa0a68909ae10c5c53469843 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import memoizee from 'memoizee'

export function Memoize (config?: memoizee.Options<any>) {
  return function (_target, _key, descriptor: PropertyDescriptor) {
    const oldFunction = descriptor.value
    const newFunction = memoizee(oldFunction, config)

    descriptor.value = function () {
      return newFunction.apply(this, arguments)
    }
  }
}