function TableUtils.shallowEqual(m,S)if m==S then return true end if type(m)~="\116\097\098\108\101"or type(S)~="\116\097\098\108\101"then return false end local P=TableUtils.keys(m)local j=TableUtils.keys(S)if#P~=#j then return false end return TableUtils.all(m,function(m,P)return m==S[P]end)end function TableUtils.serialize(m,S)S=S or function(m)return tostring(m)end assert(type(m)=="\116\097\098\108\101")assert(type(S)=="\102\117\110\099\116\105\111\110")return"\123"..(table.concat(TableUtils.map(m,function(m,P)return tostring(P)..("\061"..S(m))end),"\044").."\125")end function TableUtils.append(...)local m={}for S=1,select("\035",...),1 do local P=select(S,...)if type(P)=="\116\097\098\108\101"then for S,P in ipairs(P)do table.insert(m,P)end else table.insert(m,P)end end return m end return TableUtils
-- Based on https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/update/using_should_component_update.html
function TableUtils.shallowEqual(left, right)
	if left == right then
		return true
	end
	if type(left) ~= "table" or type(right) ~= "table" then
		return false
	end
	local leftKeys = TableUtils.keys(left)
	local rightKeys = TableUtils.keys(right)
	if #leftKeys ~= #rightKeys then
		return false
	end
	return TableUtils.all(left, function(value, key)
		return value == right[key]
	end)
end

function TableUtils.serialize(input, serializer)
	serializer = serializer or function(value)
		return tostring(value)
	end
	assert(type(input) == "table")
	assert(type(serializer) == "function")
	return "{"
		.. table.concat(
			TableUtils.map(input, function(element, i)
				return tostring(i) .. "=" .. serializer(element)
			end),
			","
		)
		.. "}"
end

function TableUtils.append(...)
	local result = {}
	for i = 1, select("#", ...) do
		local x = select(i, ...)
		if type(x) == "table" then
			for _, y in ipairs(x) do
				table.insert(result, y)
			end
		else
			table.insert(result, x)
		end
	end

	return result
end

return TableUtils
