Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bytebit-org/roblox-must

A simple function that just errors out if the value it is given is nil / undefined.
https://github.com/bytebit-org/roblox-must

game-development lua luau npm-package roblox roblox-ts

Last synced: 6 days ago
JSON representation

A simple function that just errors out if the value it is given is nil / undefined.

Awesome Lists containing this project

README

        

# Must



CI status


PRs Welcome


License: MIT


Discord server

Must is just a simple function that errors out if the argument is nil / undefined.

## Installation
### roblox-ts
Simply install to your [roblox-ts](https://roblox-ts.com/) project as follows:
```
npm i @rbxts/must
```

### Wally
[Wally](https://github.com/UpliftGames/wally/) users can install this package by adding the following line to their `Wally.toml` under `[dependencies]`:
```
Must = "bytebit/[email protected]"
```

Then just run `wally install`.

### From model file
Model files are uploaded to every release as `.rbxmx` files. You can download the file from the [Releases page](https://github.com/Bytebit-Org/roblox-Must/releases) and load it into your project however you see fit.

### From model asset
New versions of the asset are uploaded with every release. The asset can be added to your Roblox Inventory and then inserted into your Place via Toolbox by getting it [here.](https://www.roblox.com/library/9164403107/Warn-Function)

## Documentation
Documentation can be found [here](https://github.com/Bytebit-Org/roblox-Must/tree/master/docs), is included in the TypeScript files directly, and was generated using [TypeDoc](https://typedoc.org/).

## Example
Here's a simple example of a function that just wants to throw if the value it looks up is `nil` / `undefined`.

roblox-ts example

```ts
import { must } from "@rbxts/must";

export class Foo {
public bar() {
const fetchedValue = must(fetchSomeValue());

// more logic
}
}
```

Luau example

```lua
local must = require(path.to.modules["must"]).must

local Foo = {}
Foo.__index = Foo

function new()
local self = {}
setmetatable(self, Foo)

return self
end

function Foo:bar()
local fetchedValue = must(fetchSomeValue())

-- more logic
end

return {
new = new
}
```