{"id":"eyycheev/pretty-format","name":"pretty-format","scope":"eyycheev","platform":"roblox","description":"Mirrored from the Wally registry.","version":"3.14.0-rbx.2","latest":"3.14.0-rbx.2","versions":["3.14.0-rbx.0","3.14.0-rbx.1","3.14.0-rbx.2"],"license":"MIT","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{"eyycheev/chalk-lua":{"version":"^3.14.0-rbx.2","alias":"ChalkLua"},"eyycheev/jest-get-type":{"version":"^3.14.0-rbx.2","alias":"JestGetType"},"jsdotlua/luau-polyfill":{"version":"^1.2.7","alias":"LuauPolyfill"},"jsdotlua/react-is":{"version":"^17.2.1","alias":"ReactIs"},"jsdotlua/luau-regexp":{"version":"^0.2.1","alias":"RegExp"},"eyycheev/roblox-shared":{"version":"^3.14.0-rbx.2","alias":"RobloxShared"}},"integrity":"be3c6d14371ecadb63aa7472c0fb3c7e73236175eac9f9d2a59e89fb10f111cd","likes":0,"downloads":0,"install":"forest install eyycheev/pretty-format","url":"https://forest.dev/p/roblox/eyycheev/pretty-format","files":"https://api.forest.dev/ai/package/roblox/eyycheev/pretty-format/files","readme":"# pretty-format\r\n\r\nUpstream: https://github.com/facebook/jest/tree/v27.4.7/packages/pretty-format\r\n\r\nStringify any Luau value\r\n* Supports Luau builtins and Roblox Instances.\r\n* Can be extended with user defined plugins.\r\n\r\n---\r\n\r\n## Roblox Instance Formatting Options\r\n\r\nThe following options control how Roblox `Instance` objects are serialized:\r\n\r\n### `printInstanceDefaults` \\[boolean]\r\n\r\nDefault: `true`\r\n\r\nWhen `true`, prints all readable properties of an Instance. When `false`, only prints properties that differ from their default values.\r\n\r\n```lua\r\nlocal prettyFormat = require(Packages.PrettyFormat).default\r\nlocal RobloxInstance = require(Packages.PrettyFormat).plugins.RobloxInstance\r\n\r\nlocal label = Instance.new(\"TextLabel\")\r\nlabel.Text = \"Hello\"\r\n\r\n-- With printInstanceDefaults = false, only non-default properties are shown\r\nprint(prettyFormat(label, {\r\n    plugins = { RobloxInstance },\r\n    printInstanceDefaults = false,\r\n}))\r\n-- Output: TextLabel { \"Text\": \"Hello\" }\r\n```\r\n\r\n### `printInstanceTags` \\[boolean]\r\n\r\nDefault: `false`\r\n\r\nWhen `true`, prints tags applied to an Instance (via `CollectionService:AddTag()` or `React.Tag`). Tags are sorted alphabetically and appear before properties.\r\n\r\n```lua\r\nlocal label = Instance.new(\"TextLabel\")\r\nlabel.Name = \"MyLabel\"\r\nlabel:AddTag(\"Styled\")\r\nlabel:AddTag(\"Animated\")\r\n\r\nprint(prettyFormat(label, {\r\n    plugins = { RobloxInstance },\r\n    printInstanceDefaults = false,\r\n    printInstanceTags = true,\r\n}))\r\n-- Output:\r\n-- TextLabel {\r\n--   \"Tags\": Table {\r\n--     \"Animated\",\r\n--     \"Styled\",\r\n--   },\r\n--   \"Name\": \"MyLabel\",\r\n-- }\r\n```\r\n\r\n### `useStyledProperties` \\[boolean]\r\n\r\nDefault: `false`\r\n\r\nWhen `true`, reads Instance properties using the `GetStyled` API, returning computed values after StyleSheet rules are applied. When `false`, reads properties directly from the Instance.\r\n\r\nThis is useful when testing styled components to verify that style rules are correctly applied.\r\n\r\n```lua\r\n-- With useStyledProperties = true, the styled value (from StyleSheet) is shown\r\n-- With useStyledProperties = false, the base property value is shown\r\n```\r\n\r\n**Note on Pseudoinstances:** Styling infrastructure instances (`StyleSheet`, `StyleRule`, `StyleLink`, `StyleDerive`) currently appear in serialized output when they are children of a formatted Instance. This behavior is documented and tested in the test suite.\r\n\r\n---\r\n\r\n### :pencil2: Notes\r\n* :warning: Our `prettyFormat` doesn't distinguish between `Tables`, `Arrays`, `Objects`, etc. and prints out all Lua table-like types as `Table`.\r\n    * For example, an empty array is printed as `Table {}` and an array with values is printed as `Table {1, 2, 3,}`.\r\n    * `printComplexValue` is reduced to just arrays and tables.\r\n* :x: Color formatting isn't supported so all related methods are omitted.\r\n* :hammer: Built-in plugins for `prettyFormat` are not implemented yet.\r\n* `prettyFormat` formats Roblox `DateTime` objects as a replacement for JS `Date`.\r\n* Formats using the Lua native string representations of primitives like `nil`, `nan` and `inf` over the JS `null`, `NaN` and `Infinity`. The tests are modified accordingly.\r\n* Formatting for any Javascript specific types in are omitted, `Symbol`, named `Function`, `Error`, `Date`, `BigInt`, etc.\r\n* `getConfig` is rewritten to avoid ternary operators.\r\nloop is rewritten with a `for` loop instead of an `iterator.next()`.\r\n* `Collections.lua` deviates from upstream substantially since Lua only has tables. We only have two functions: `printTableEntries` for formatting key, value pairs and `printListItems` for formatting arrays.\r\n","readmeTruncated":false}