inspect

Human-readable representations of Lua objects

Provides a simple callable that makes Lua objects human readable. Normally, if you try to print(table), Lua just prints something like table: 0xbecb40. This library instead returns a human readable view of the actual contents of the table.

Info

Version: 3.0.0
Author: Enrique GarcĂ­a Cota
License: MIT
Copyright: 2013

Functions

Name Summary
__call

Convert Lua objects to a human-readable representation

Functions : inspect

__call(data, depth, newline, indent, process)

Convert Lua objects to a human-readable representation This converts any Lua object into a human-readable string. It can accept numbers, strings, or (most usefully) tables as arguments. It is generally not able to inspect userdata type objects. More detailed docs can be found at github.

Parameters
Name Type Default Summary

data

any

A Lua object which you want to inspect.

depth

number or nil

math.huge

Sets the max depth to print out; defaults to basically infinite

newline

string

“\n”

Defines a string to add for new lines (defaults to a newline char)

indent

string

“ ”

Defines a string to add for each level of indent (defaults to 2 spaces)

process

function

A function used to filter data in the object. Please see the github page for detailed information about how to use this.

Returns
Type Summary

string

A string representation of all the items in your table

Usage
inspect = require "inspect"
my_data = { x="foo", y="bar", z={ a="baz" } }
print(inspect(my_data)) -- prints:
-- {
--   x = "foo",
--   y = "bar",
--   z = {
--     a = "baz"
--   }
-- }