
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@snomiao/die
Advanced tools
|| DIE('reason') Throws an error like PHP 's `OR DIE('REASON')`, Simple error throwing in a functional dev style.
|| DIE('reason') Throws an error like PHP's or DIE('REASON'), Simple error throwing in a functional dev.
import DIE from 'phpdie'
const token = process.env.TOKEN ?? DIE("Missing Token")
console.log(token) // typeof token === "string"
The DIES function allows you to call an alert function (like alert, console.error, toast.error, etc.) and then throw an error. This is useful for showing error messages to users before terminating execution.
import { DIES } from '@snomiao/die'
const ooops = false
// With alert
ooops || DIES(alert, "Something went wrong!");
// With console.error
ooops || DIES(console.error, "Error:", 404, "Not Found");
// With toast notifications
ooops || DIES(toast.error, "Failed to save data");
// With custom alert function
const showError = (msg) => { /* show error in UI */ };
ooops || DIES(showError, "Custom error message");
ooops || DIES(()=> 'anyway die');
The DIES function:
cause propertynever)import DIE from ".";
it("lives", () => {
const token = "123" ?? DIE("Missing Token");
console.log(token);
expect(token).toEqual("123");
});
it("dies", () => {
let err: any;
try {
const token = process.env.TOKEN ?? DIE("Missing Token");
console.log(token);
} catch (e) {
err = e;
}
expect(err).toEqual("Missing Token");
});
it("dies with error", () => {
let err: any;
try {
const token = process.env.TOKEN ?? DIE(new Error("Missing Token"));
console.log(token);
} catch (e) {
err = e;
}
expect(err.message).toEqual("Missing Token");
});
export function DIE(reason?: string | Error): never {
if (typeof reason === "string") {
const err = new Error(reason);
throw err.stack;
}
throw reason;
}
FAQs
|| DIE('reason') Throws an error like PHP 's `OR DIE('REASON')`, Simple error throwing in a functional dev style.
We found that @snomiao/die 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.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.