{"id":"duckarmor/freeze","name":"freeze","scope":"duckarmor","platform":"roblox","description":"Immutable data structures for Roblox Luau ❄️","version":"0.1.1","latest":"0.1.1","versions":["0.0.1","0.1.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"216b418faae9d0de7199da498751bc9f039270750db24d7f6ba7658201288a5a","likes":0,"downloads":0,"install":"forest install duckarmor/freeze","url":"https://forest.dev/p/roblox/duckarmor/freeze","files":"https://api.forest.dev/ai/package/roblox/duckarmor/freeze/files","readme":"# Installation\n\n## With Wally\n\n```toml\n[dependencies]\nFreeze = \"duckarmor/freeze@0.1.1\"\n```\n\n<!--moonwave-hide-before-this-line-->\n# Freeze\n\nFreeze is an immutable data structure library for Roblox Luau.\n\nBe sure to read the [documentation](https://duckarmor.github.io/Freeze/)!\n\nImmutable data structures are imperative for use with popular libraries such as React and Rodux. To learn more about why immutability is important, check out our [How does immutability help?](https://duckarmor.github.io/Freeze/docs/WhyImmutable) page.\n\nFreeze is typed and currently used in several duckarmor projects.\n\nUse Freeze to create immutable data structures like so:\n\n```lua\nlocal map1 = { a = 1, b = 2, c = 3 }\nlocal map2 = Freeze.Dictionary.set(map1, \"b\", 50)\n\nprint(map1.b, \"vs\", map2.b)\n-- 2 vs 50\n```\n\nFreeze will optimize return calls in such that it will return the original list or dictionary if no changes were made:\n```lua\nlocal map1 = { a = 1 }\nlocal map2 = Freeze.Dictionary.set(map1, \"a\", 1)\n\nprint(map1 == map2)\n-- true; because no changes were made\n```\nTrue to it's name, Freeze will return calls of new values wrapped in `table.frozen`. Return values that are not changed will not be `table.frozen`'d to preserve the caller's frozen status.\n\n## Nested Data Structures\nFreeze also has a few power tools at your disposal to allow for reading and operating on nested data structures. These include [`getIn`](/api/Dictionary#getIn), [`setIn`](/api/Dictionary#setIn), [`mergeIn`](/api/Dictionary#mergeIn), and [`updateIn`](/api/Dictionary#updateIn), found on [`Dictionary`](/api/Dictionary).\n\n## Freeze's General Philosophy\n\nFreeze aims to\n- Be type safe. Types are represented in such that there are no false negative type errors.\n- Be runtime safe. Errors will not propagate unless you are passing invalid values that the Luau type checker would have caught.\n- Enforce immutability via `table.frozen`\n- Optimize return values if no changes were made within the operation by returning the original value.\n\n\n## Prior art\n\nFreeze takes inspiration from:\n- [Llama by freddylist](https://github.com/freddylist/llama)\n- [Immutable.js](https://immutable-js.com/)\n\n\n## Demos\nSee [demonstrations](https://benbrimeyer.github.io/Freeze/docs/Demonstration) within our docs!\n","readmeTruncated":false}