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