aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/memoize.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-09 10:29:23 +0100
committerChocobozzz <me@florianbigard.com>2023-01-09 10:29:23 +0100
commiteb66ee88351a93eb68c366cfbe30d35ed7c57b03 (patch)
treefb2ebb3b5accbbf06438709ae7e222f7ea7c9ffd /server/helpers/memoize.ts
parent0a8a79552cf59c800011c9f63eaa8658230acddc (diff)
downloadPeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.tar.gz
PeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.tar.zst
PeerTube-eb66ee88351a93eb68c366cfbe30d35ed7c57b03.zip
Refactor table attributes
Diffstat (limited to 'server/helpers/memoize.ts')
-rw-r--r--server/helpers/memoize.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/server/helpers/memoize.ts b/server/helpers/memoize.ts
new file mode 100644
index 000000000..aa20e7d73
--- /dev/null
+++ b/server/helpers/memoize.ts
@@ -0,0 +1,12 @@
1import memoizee from 'memoizee'
2
3export function Memoize (config?: memoizee.Options<any>) {
4 return function (_target, _key, descriptor: PropertyDescriptor) {
5 const oldFunction = descriptor.value
6 const newFunction = memoizee(oldFunction, config)
7
8 descriptor.value = function () {
9 return newFunction.apply(this, arguments)
10 }
11 }
12}