diff options
| author | ruki <[email protected]> | 2016-03-18 13:52:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-18 13:52:32 +0800 |
| commit | 34d77b966b9640673b4a6d23758b3d9f51cb1169 (patch) | |
| tree | 70c1e09a27dd09bc1b6825d227fb8ee10ff04a58 /xmake/core/base/utils.lua | |
| parent | 8f5125ae1329d24b5265c4cb45b1890c3f175e60 (diff) | |
rename utils.wrap and unique
Diffstat (limited to 'xmake/core/base/utils.lua')
| -rw-r--r-- | xmake/core/base/utils.lua | 75 |
1 files changed, 1 insertions, 74 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index 3ff7283fe..bfb5469af 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -104,79 +104,6 @@ function utils.ifelse(a, b, c) if a then return b else return c end end --- unwrap object if be only one -function utils.unwrap(object) - - -- check - assert(object) - - -- unwrap it - if type(object) == "table" and table.getn(object) == 1 then - for _, v in pairs(object) do - return v - end - end - - -- ok - return object -end - --- wrap object to table -function utils.wrap(object) - - -- no object? - if not object then - return {} - end - - -- wrap it if not table - if type(object) ~= "table" then - return {object} - end - - -- ok - return object -end - --- remove repeat from the given array -function utils.unique(array) - - -- check - assert(array) - - -- remove repeat - if type(array) == "table" then - - -- not only one? - if table.getn(array) ~= 1 then - - -- done - local exists = {} - local unique = {} - for _, v in ipairs(array) do - if type(v) == "string" then - if not exists[v] then - exists[v] = true - table.insert(unique, v) - end - else - local key = "\"" .. tostring(v) .. "\"" - if not exists[key] then - exists[key] = true - table.insert(unique, v) - end - end - end - - -- update it - array = unique - end - end - - -- ok - return array -end - -- call functions function utils.call(funcs, pred, ...) @@ -184,7 +111,7 @@ function utils.call(funcs, pred, ...) assert(funcs) -- call all - for _, func in ipairs(utils.wrap(funcs)) do + for _, func in ipairs(table.wrap(funcs)) do -- check assert(type(func) == "function") |
