From 8052e62aacc6cef9f24379d85603f341bc475efc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 26 Jan 2024 21:53:51 +0300 Subject: [PATCH 1/2] fix(utils): Correct API docs for memoize() which only handles one arg --- lua/pl/utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua index cbba03fe..5a357a3f 100644 --- a/lua/pl/utils.lua +++ b/lua/pl/utils.lua @@ -749,8 +749,8 @@ end -- This is useful if you have a function which is relatively expensive, -- but you don't know in advance what values will be required, so -- building a table upfront is wasteful/impossible. --- @param func a function of at least one argument --- @return a function with at least one argument, which is used as the key. +-- @param func a function that takes exactly one argument +-- @return a function taking one argument, which is used as the cache key. function utils.memoize(func) local cache = {} return function(k) From 98a811916f32d84f2bf4fc29e88134e42608b9f7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Jan 2024 10:47:12 +0300 Subject: [PATCH 2/2] fix(utils): Clarify API docs that memoize() only returns one value --- lua/pl/utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua index 5a357a3f..85b7c8b2 100644 --- a/lua/pl/utils.lua +++ b/lua/pl/utils.lua @@ -749,8 +749,8 @@ end -- This is useful if you have a function which is relatively expensive, -- but you don't know in advance what values will be required, so -- building a table upfront is wasteful/impossible. --- @param func a function that takes exactly one argument --- @return a function taking one argument, which is used as the cache key. +-- @param func a function that takes exactly one argument (which later serves as the cache key) and returns a single value +-- @return a function taking one argument and returning a single value either from the cache or by running the original input function function utils.memoize(func) local cache = {} return function(k)