
Security News
OpenGrep Restores Fingerprinting in JSON and SARIF Outputs
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
clean-function
Advanced tools
A replacement for using try-catch in JavaScript/TypeScript!
It seems like a lot of people are stuck in the try-catch nightmare, so I built a better, clean, and type-safe solution.
You just wrap any function you have with the cleanFunction
that you get from the package and you're good to go. Instead of using try-catch, you do it like this:
import { cleanFunction } from "f-try-catch";
const myFunction = cleanFunction(async (args: ANY_ARGS) => {
// do anything you want
})
const { data, error } = await myFunction(args);
if (error === null) {
console.log(data); // handle the data
} else {
// handle errors
}
This package is intended to be used anywhere: the browser, Node.js, Deno, the edge, and it has no dependencies, install:
npm install f-try-catch
or using any other package manager you use in your project.
Using this package is so simple, you just wrap your function with cleanFunction
.
import { cleanFunction } from "f-try-catch";
const sum = cleanFunction(async (a: number, b: number) => {
// do anything you want here
return a + b;
});
const { data, error } = await sum(1, 2);
if (error === null) {
console.log(data); // number (3)
} else {
// handle errors as you want
console.error(error);
}
import { cleanFunctionSync } from "f-try-catch";
const mySyncFunction = cleanFunctionSync((a: number, b: number) => {
return a + b;
});
const { data, error } = mySyncFunction(1, 2);
if (error === null) {
console.log(data); // number (3)
} else {
// handle errors as you want
console.error(error);
}
Made with ❤️ by Kais Radwan
FAQs
A clean type-safe replacement for using try-catch
The npm package clean-function receives a total of 0 weekly downloads. As such, clean-function popularity was classified as not popular.
We found that clean-function demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.