1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 05:40:05 +08:00
SpaceVim/bundle/plenary.nvim/lua/plenary/fun.lua
2022-05-16 22:20:10 +08:00

38 lines
601 B
Lua

local tbl = require "plenary.tbl"
local M = {}
function M.bind(fn, ...)
if select("#", ...) == 1 then
local arg = ...
return function(...)
fn(arg, ...)
end
end
local args = tbl.pack(...)
return function(...)
fn(tbl.unpack(args), ...)
end
end
function M.arify(fn, argc)
return function(...)
if select("#", ...) ~= argc then
error(("Expected %s number of arguments"):format(argc))
end
fn(...)
end
end
function M.create_wrapper(map)
return function(to_wrap)
return function(...)
return map(to_wrap(...))
end
end
end
return M