A clean Utility Library for Lua inspired by Underscore and LoDash, support for basic and useful function, make it easy to write Lua code neatly
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
.travis.yml
dist.ini
readme.md

readme.md

Shim.lua

build status

A clean utility library, support for basic and useful function, make it easy to write lua code neatly

document

Shim.lua was deeply inspired by Underscore.js, Lodash.js, Moses

Install

Use opm

opm get chunpu/shim

Download directly

wget --no-check-certificate https://raw.githubusercontent.com/chunpu/Shim/master/shim.lua

Usage

local _ = require 'shim'

_.isArray({1, 2, 3}) -- => true
_.isEqual({a = 1, b = 2}, {a = 1, b = 2}) -- => true

basic wrapper for oo style

_({1, 2, 3}):map(function(x) return x * 2 end)
-- => {2, 4, 6}

chain support

_({1, 0, 2, 4})
	:chain()
	:sort()
	:map(function(x) return x * 2 end)
	:filter(function(x) return x < 6 end)
	:value()
-- => {0, 2, 4}

pretty print

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/

License

Shim.lua is under MIT

Copyright (c) 2012-2014 Chunpu