diff options
Diffstat (limited to 'lua/nvim-lsp-installer/data.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/data.lua | 14 |
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 |
