
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@nightcycle/option
Advanced tools
A safer alternative to null.
It's a pretty lightweight package.
You can create a new option via a few methods
-- none() creates the option as none
local character: Option<Model> = Option.none()
-- from() accepts a possibly null value, creating as some if not null
character = Option.from(player.Character)
-- some() will error if it receives a null value, but always creates the option as some
character = if player.Character then Option.some(player.Character) else Option.none()
-- try runs a function to get the value (use from if state is static)
character = Option.try(function(): Character?
return player.Character
end)
The package interface has a few handy methods.
-- map() is also a class method, but this allows for type changing
local name: Option<string> = Option.map(character, function(char: Model)
return char.Name
end)
-- isOption() checks if an unknown value is an option
assert(Option.isOption(name), `name is not an option`)
-- supports `osyrisrblx/t` standard runtime type refinement
local isAModelOption = Option.type(t.instanceIsA("Model"))
local success, message = isAModelOption(name) -- I know, `message = string?`, it's the standard - we can't dump null overnight
For checking the state of the option:
if name:isSome() then
print("name is some!")
end
if name:isNone() then
print("name is none!")
end
-- only runs when some, otherwise it's passed over
name:inspect(function(str)
print(`name is "{str}"!`)
end)
For extracting the state of the option:
-- if the option is none, the thread panics
local nameStr = name:unwrap()
nameStr = name:expect(`name is none()`) -- same as unwrap, but custom error message
-- both functions need to return the same type, used for flattening the option
nameStr = name:match(function(some)
return name
end, function()
return "Default Name"
end)
-- if you don't need to process the some() value, unwrapOr is a handy alternative
nameStr = name:unwrapOr("Default Name")
-- only calls the function if there's a none value - good for performance if getting the value is process heavy
nameStr = name:unwrapOrElse(function()
return "Default Name"
end)
local maybeNameStr: string? = name:asNullable() -- most of the ecosystem uses null values, it's silly to pretend otherwise
-- constructs a new option with the return value of the callback
local lowerCaseName: Option<string> = name:map(function(some)
return some:lower()
end)
If you like this, check out my suite of rust inspired packages: bloxidize
FAQs
A basic port of the rust Option class
We found that @nightcycle/option demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.