aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/data.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer/data.lua')
-rw-r--r--lua/nvim-lsp-installer/data.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/data.lua b/lua/nvim-lsp-installer/data.lua
index b5689142..d9764bee 100644
--- a/lua/nvim-lsp-installer/data.lua
+++ b/lua/nvim-lsp-installer/data.lua
@@ -106,4 +106,18 @@ function Data.json_decode(data)
end
end
+function Data.memoize(fn, cache_key_generator)
+ cache_key_generator = cache_key_generator or function(a)
+ return a
+ end
+ local cache = {}
+ return function(...)
+ local key = cache_key_generator(...)
+ if not cache[key] then
+ cache[key] = fn(...)
+ end
+ return cache[key]
+ end
+end
+
return Data