shim
一个干净的 Lua 工具库,支持基本和有用的功能,灵感来自 loDash 和 Underscore
$ opm get chunpu/shim
Shim.lua
[![build status][travis-image]][travis-url]
一个干净的工具库,支持基本和有用的功能,使编写 Lua 代码更简洁
Shim.lua
深受 Underscore.js、Lodash.js、Moses 的启发
安装
使用 opm
opm get chunpu/shim
直接下载
wget --no-check-certificate https://raw.githubusercontent.com/chunpu/Shim/master/shim.lua
用法
local _ = require 'shim'
_.isArray({1, 2, 3}) -- => true
_.isEqual({a = 1, b = 2}, {a = 1, b = 2}) -- => true
面向对象风格的基本包装器
_({1, 2, 3}):map(function(x) return x * 2 end)
-- => {2, 4, 6}
支持链式调用
_({1, 0, 2, 4})
:chain()
:sort()
:map(function(x) return x * 2 end)
:filter(function(x) return x < 6 end)
:value()
-- => {0, 2, 4}
美观打印
print(_.dump({
a = 1,
b = {
a = 1,
b = {2, 3, 4}
}
}))
--[[ =>
{
'b': {
'b': [2, 3, 4],
'a': 1
},
'a': 1
}
]]
API
<http://chunpu.github.io/shim-doc/>
许可证
Shim.lua 采用 MIT 许可证
版权所有 (c) 2012-2014 Chunpu
[travis-image]: https://img.shields.io/travis/chunpu/Shim.svg?style=flat [travis-url]: https://travis-ci.org/chunpu/Shim
作者
chunpu
许可证
mit
版本
-
chunpu/shim 1.0.2一个干净的 Lua 工具库,支持基本和有用的功能,灵感来自 loDash 和 Underscore 2016-10-16 10:08:09
-
chunpu/shim 1.0.0一个干净的 Lua 工具库,支持基本和有用的功能,使编写 Lua 代码更简洁 2016-10-13 11:14:51