Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dumpvar & exportvar #350

Merged
merged 6 commits into from
Sep 2, 2023
Merged

Add dumpvar & exportvar #350

merged 6 commits into from
Sep 2, 2023

Conversation

Sainan
Copy link
Member

@Sainan Sainan commented Sep 1, 2023

The original goal was table.dump (#337), but I ended up being a bit inspired by PHP's var_dump and var_export.

local t = {
	[1] = "a",
	[2] = "b",
	["a"] = 1,
	["b"] = 2,
	["t"] = {
		["deez"] = "nuts"
	}
}
t["r"] = t
print(dumpvar(t))

Possible output:

{
        [1] = "a",
        [2] = "b",
        ["a"] = 1,
        ["b"] = 2,
        ["r"] = *RECURSION*,
        ["t"] = {
                ["deez"] = "nuts",
        },
}

TODO:

  • Quote strings
  • Add exportvar that guarantees valid Lua code, so errors on recursion

@Sainan Sainan changed the title Add dump Add dumpvar & exportvar Sep 2, 2023
@well-in-that-case well-in-that-case merged commit e539569 into 0.8.0 Sep 2, 2023
6 checks passed
@well-in-that-case well-in-that-case deleted the vardump branch September 2, 2023 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants