
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
early-return
Advanced tools
Helper to facilitate early returns across function stack in JavaScript.
Helper to facilitate early returns across function stack in JavaScript.
import { early, earlyReturn } from 'early-return'
function handler() {
early(1, true) // Will return, value 1.
early(2, false) // Will be skipped, no value.
early(3) // Will return, value 3.
}
const value = earlyReturn(handler)
This plugin is especially useful when integrated directly into frameworks, so that the overhead of wrapping functions isn't necessary. The following example shows how it simplifies JSX components.
function MyComponent() {
if (Store.loading) {
return <p>Loading...</p>
}
if (Store.error) {
return <p>Error!</p>
}
return <p>Hello World!</p>
}
function MyComponent() {
early(<p>Loading...</p>, Store.loading)
early(<p>Error!</p>, Store.error)
return <p>Hello World!</p>
}
Most importantly early
can also be called in nested methods forcing the execution of all earlier methods to stop as well.
FAQs
Helper to facilitate early returns across function stack in JavaScript.
The npm package early-return receives a total of 2 weekly downloads. As such, early-return popularity was classified as not popular.
We found that early-return 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.