Improve typings

This commit is contained in:
hrsh7th
2022-07-24 12:44:53 +09:00
parent 89df2cb223
commit bf5593df8e
24 changed files with 154 additions and 130 deletions

View File

@@ -9,7 +9,7 @@ cache.new = function()
end
---Get cache value
---@param key string
---@param key string|string[]
---@return any|nil
cache.get = function(self, key)
key = self:key(key)
@@ -20,7 +20,7 @@ cache.get = function(self, key)
end
---Set cache value explicitly
---@param key string
---@param key string|string[]
---@vararg any
cache.set = function(self, key, value)
key = self:key(key)
@@ -28,8 +28,10 @@ cache.set = function(self, key, value)
end
---Ensure value by callback
---@param key string
---@param callback fun(): any
---@generic T
---@param key string|string[]
---@param callback fun(): T
---@return T
cache.ensure = function(self, key, callback)
local value = self:get(key)
if value == nil then
@@ -46,7 +48,7 @@ cache.clear = function(self)
end
---Create key
---@param key string|table
---@param key string|string[]
---@return string
cache.key = function(_, key)
if type(key) == 'table' then