lua-resty-object
lua object inspired by javascript object and array
$ opm get xiangnanscu/lua-resty-object
lua-resty-object
lua object inspired by javascript object
install
opm get xiangnanscu/lua-resty-object
Synopsis
local object = require("resty.object")
assert(object{a=1,b=2,c=3}:keys():as_set() == array{'a','b','c'}:as_set())
assert(object{a=1,b=2,c=3}:values():as_set() == array{1,2,3}:as_set())
assert(object{a=1,b=2} == object{a=1,b=2})
assert(object{a=1,b={c=3,d=4}} == object{a=1,b={c=3,d=4}})
assert(object{a=1,b={c=3,d=4}} ~= object{a=1,b={c=3,d=5}})
assert(object{a=1}:assign({b=2}, {c=3}) == object{a=1,b=2,c=3})
assert(object.from_entries(object{a=1,b=2}:entries():map(function(e) return {'k'..e[1], 100 + e[2]} end)) == object{ka=101,kb=102})
api
object.assign(t, ...)
object.keys()
object.values()
object.entries()
object.from_entries(t)
object.equals(t, o)
deeply compare if t
equals o
.
object.contains(t, o)
deeply compare if t
contains o
.
test
busted .
Authors
Nan Xiang(@xiangnanscu)
License
mit
Versions
-
lua object inspired by javascript object and array 2024-03-20 01:41:01
-
lua object inspired by javascript object and array 2023-08-31 09:16:09
-
lua object inspired by javascript object and array 2023-08-31 04:02:14
-
lua object inspired by javascript object and array 2023-08-30 04:19:43
-
lua object inspired by javascript object 2023-08-29 10:01:35
-
lua object inspired by javascript object 2022-03-16 03:05:53
-
lua object inspired by javascript object 2022-03-15 23:37:44
-
lua object inspired by javascript object 2022-03-15 16:05:04