403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/laragon2/bin/cmder/vendor/clink-completions/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/laragon2/bin/cmder/vendor/clink-completions/modules/tables.lua
local concat = require('funclib').concat
local filter = require('funclib').filter
local map = require('funclib').map
local reduce = require('funclib').reduce

local exports = {}

local wrap_filter = function (tbl, filter_func)
    return exports.wrap(filter(tbl, filter_func))
end

local wrap_map = function (tbl, map_func)
    return exports.wrap(map(tbl, map_func))
end

local wrap_reduce = function (tbl, accum, reduce_func)
    local res = reduce(accum, tbl, reduce_func)
    return (type(res) == "table" and exports.wrap(res) or res)
end

local wrap_concat = function (tbl, ...)
    return exports.wrap(concat(tbl, ...))
end

local wrap_print = function (tbl)
    return exports.wrap(filter(tbl, function (item)
        print(item)
        return true
    end))
end

exports.wrap = function (tbl)
    if tbl == nil then tbl = {} end
    if type(tbl) ~= "table" then tbl = {tbl} end

    local mt = getmetatable(tbl) or {}
    mt.__index = mt.__index or {}
    mt.__index.filter = wrap_filter
    mt.__index.map = wrap_map
    mt.__index.reduce = wrap_reduce
    mt.__index.concat = wrap_concat
    mt.__index.print = wrap_print
    mt.__index.keys = function (tbl)
        local res = {}
        for k,_ in pairs(tbl) do
            table.insert(res, k)
        end
        return exports.wrap(res)
    end
    mt.__index.sort = function (tbl)
        table.sort(tbl)
        return tbl
    end
    mt.__index.dedupe = function (tbl)
        local res, hash = {}, {}
        for _,v in ipairs(tbl) do
            if not hash[v] then
                hash[v] = true
                table.insert(res, v)
            end
        end
        return exports.wrap(res)
    end
    mt.__index.contains = function (tbl, value)
        local res, hash = {}, {}
        for _,v in ipairs(tbl) do
            if v == value then return true, _ end
        end
        return false
    end

    return setmetatable(tbl, mt)
end

return exports

Youez - 2016 - github.com/yon3zu
LinuXploit