From 8eb5047a3f54396f0e9e85c2ca8fb039ca9523c0 Mon Sep 17 00:00:00 2001 From: Danbaba1 <98762494+Danbaba1@users.noreply.github.com> Date: Mon, 20 Jun 2022 13:54:36 +0100 Subject: [PATCH] coordinate exercise --- coordinate | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 coordinate diff --git a/coordinate b/coordinate new file mode 100644 index 0000000..de8da4c --- /dev/null +++ b/coordinate @@ -0,0 +1,12 @@ + +export function memoizeTransform(f) { + const cache = {}; + return function memoize(...args){ + if(cache[args]){ + return cache[args] + } + const result = f.apply(this,args); + cache[args] = result; + }; + return result; +}