File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11local concat = table.concat
22local unpack = unpack or table.unpack
3+ local type = type
34local moon = {
45 is_object = function (value )
56 return type (value ) == " table" and value .__class
67 end ,
8+ is_a = function (thing , t )
9+ if not (type (thing ) == " table" ) then
10+ return false
11+ end
12+ local cls = thing .__class
13+ while cls do
14+ if cls == t then
15+ return true
16+ end
17+ cls = cls .__parent
18+ end
19+ return false
20+ end ,
721 type = function (value )
822 local base_type = type (value )
923 if base_type == " table" then
Original file line number Diff line number Diff line change 22import concat from table
33
44unpack = unpack or table. unpack
5+ type = type
56
67moon =
78 is_object : ( value) -> -- is a moonscript object
89 type ( value) == " table" and value. __class
10+
11+ is_a : ( thing, t) ->
12+ return false unless type ( thing) == " table"
13+ cls = thing. __class
14+ while cls
15+ if cls == t
16+ return true
17+ cls = cls. __parent
18+
19+ false
20+
921 type : ( value) -> -- the moonscript object class
1022 base_type = type value
1123 if base_type == " table"
You can’t perform that action at this time.
0 commit comments