@rbxts/must
v1.0.5
Published
Just a simple function that errors out if the argument is nil / undefined.
Downloads
15
Readme
Must
Must is just a simple function that errors out if the argument is nil / undefined.
Installation
roblox-ts
Simply install to your roblox-ts project as follows:
npm i @rbxts/must
Wally
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 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.
Documentation
Documentation can be found here, is included in the TypeScript files directly, and was generated using TypeDoc.
Example
Here's a simple example of a function that just wants to throw if the value it looks up is nil
/ undefined
.
import { must } from "@rbxts/must";
export class Foo {
public bar() {
const fetchedValue = must(fetchSomeValue());
// more logic
}
}
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
}