{"id":"cosinewaves/lambda","name":"lambda","scope":"cosinewaves","platform":"roblox","description":"A lightweight lifecycle orchestrator","version":"0.1.4","latest":"0.1.4","versions":["0.1.0","0.1.1","0.1.2","0.1.3","0.1.4"],"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":{"lukadev-0/typed-promise":{"version":"^4.0.2","alias":"Promise"}},"integrity":"c6f1d7bcbf4efca135ed1c4714fd40d910677e37760ce1201b3bf10c3d35e23d","likes":0,"downloads":0,"install":"forest install cosinewaves/lambda","url":"https://forest.dev/p/roblox/cosinewaves/lambda","files":"https://api.forest.dev/ai/package/roblox/cosinewaves/lambda/files","readme":"![Lambda logo stolen from half-life 2 - sorry not sorry](https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/9637b521-3a6a-4454-9dd0-618c21eab620/dbyq9rd-8d256ee4-a4f7-4731-acb8-3b0f78cafbd8.png/v1/fill/w_1024,h_576,q_80,strp/half_life_lambda_by_dragonshadesx_dbyq9rd-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9NTc2IiwicGF0aCI6IlwvZlwvOTYzN2I1MjEtM2E2YS00NDU0LTlkZDAtNjE4YzIxZWFiNjIwXC9kYnlxOXJkLThkMjU2ZWU0LWE0ZjctNDczMS1hY2I4LTNiMGY3OGNhZmJkOC5wbmciLCJ3aWR0aCI6Ijw9MTAyNCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.TWGY4OxLGqkSEEyX-pe5jtvnWte27BPQFQLB6bfom58)\n\n## **λ Lambda**\nA lightweight lifecycle orchestrator for ModuleScripts. Lambda ensures a consistent init → start boot process across a list of modules, with full Promise support for async initialisation.\n\n> [!IMPORTANT]\n> **This module depends on a working lua Promise implementation (such as [`evaera/roblox-lua-promise`](https://github.com/evaera/roblox-lua-promise) ) - make sure you’ve required it correctly inside the library**\n\n\n---\n\n## 🚀 Key Features\n\n- 🔁 **Consistent Lifecycle**: Each module can optionally export `init()` and `start()` for structured loading.\n- ⏳ **Async Safety**: Modules are `required` safely, and `start()` is deferred until `init()` of all modules is complete.\n- 📦 **Batch Loading**: Load all children or descendant `ModuleScripts` from a container.\n\n---\n\n## 📦 Installation\nPlace [`lambda/init.lua`](lib/init.lua) in your project, then call it once with your target ModuleScripts:\n\n```lua\nlocal Lambda = require(path.to.lambda)\n\nlocal modules: {ModuleScript} = {\n    script.Services.PlayerService,\n    script.Services.InventoryService,\n    script.Services.MatchService,\n}\n\nLambda(modules)\n```\n\n---\n\n## 📜 Module Lifecycle\n\nEach module you load can optionally export:\n\n`init(): () | Promise`\n- Called immediately after `require()`.\n- All `init()` methods are awaited before any `start()`.\n\n`start(): () | Promise`\n- Called after every module’s `init()` has resolved.\n\n> [!TIP]\n> Both lifecycle functions are optional, you can mix and match.\n\n### Example Module:\n\n```lua\nlocal PlayerService = {}\n\nfunction PlayerService.init(): ()\n    print(\"PlayerService initializing...\")\n    return Promise.delay(1):andThen(function()\n        print(\"PlayerService init complete\")\n    end)\nend\n\nfunction PlayerService.start(): ()\n    print(\"PlayerService starting...\")\nend\n\nreturn PlayerService\n```\n\n---\n\n## 🔍 Usage Notes\n- If a module throws during require, Lambda rejects immediately.\n- If `init()` or `start()` throws, it’s caught and wrapped in a rejected Promise.\n- Non-Promise return values are automatically wrapped in `Promise.resolve()`.\n","readmeTruncated":false}