chore: add type annotations to (almost) all functions

This commit is contained in:
Akmadan23
2023-11-24 12:01:24 +01:00
parent 46e1f776f0
commit fabea3376e
48 changed files with 438 additions and 83 deletions

View File

@@ -1,10 +1,11 @@
local M = {}
---@type table[string, fun(a: node, b: node): boolean]
local C = {}
--- Predefined comparator, defaulting to name
--- @param sorter string as per options
--- @return function
---@param sorter string as per options
---@return function
local function get_comparator(sorter)
return C[sorter] or C.name
end
@@ -41,6 +42,11 @@ local function folders_or_files_first(a, b)
end
end
---@param t table
---@param first number
---@param mid number
---@param last number
---@param comparator fun(a: table, b: table): boolean
local function merge(t, first, mid, last, comparator)
local n1 = mid - first + 1
local n2 = last - mid
@@ -74,6 +80,10 @@ local function merge(t, first, mid, last, comparator)
end
end
---@param t table
---@param first number
---@param last number
---@param comparator fun(a: table, b: table): boolean
local function split_merge(t, first, last, comparator)
if (last - first) < 1 then
return
@@ -137,6 +147,10 @@ function M.sort(t)
end
end
---@param a table
---@param b table
---@param ignorecase boolean|nil
---@return boolean
local function node_comparator_name_ignorecase_or_not(a, b, ignorecase)
if not (a and b) then
return true