
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
iron-oxide
Advanced tools
Rust style exception handling in TypeScript
Documentation is hosted as an mdbook at iron-oxide.js.org.
An Option represents success or the presence of a value. It comes in two variants:
None to indicate failure or the lack of a valueSome(value) to indicate the presence of the given valueExample:
import { Option, None, Some } from 'iron-oxide';
function find<T>(array: T[], predicate: (el: T) => boolean): Option<T> {
for (const el of array) {
if (predicate(el)) {
return Some(el);
}
}
return None();
}
A Result is like Option, but it also can represent the failure state with a reason. It also comes in two variants:
Err(error) to indicate an error state, along with a message of whyOk(value) to indicate the success stateExample:
import { Result, Ok, Err } from 'iron-oxide';
function parseInt(n: string, radix: number = 10): Result<number, string> {
const value = Number.parseInt(n, radix);
if (isNaN(value)) {
return Err(`Unable to parse ${n} as an integer`);
}
return Ok(value);
}
A match statement is like a switch statement on steroids. It can be used similarly to switch, but works with more than just primitive values. Namely, you can hand it a primitive value, an object, an array, or a function which returns a boolean.
import { match } from 'iron-oxide';
function isEvenOrOdd(n: number) {
return match (n, [
[0, () => 'neitherEvenNorOdd'],
[x => x % 2 === 0, () => 'even'],
[x => x % 2 !== 0, () => 'odd']
]);
}
FAQs
Rust style exception handling in TypeScript
The npm package iron-oxide receives a total of 5 weekly downloads. As such, iron-oxide popularity was classified as not popular.
We found that iron-oxide demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.