Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Inspired by Elixir's cond
this is a simpler alternative to lodash's _.cond
Install with npm or yarn via
yarn add cond-flow
or
npm i cond-flow
import cond from 'cond-flow'
const value = cond([
[false, 'false'],
[true, 'true'],
[true, 'true but too late'],
])
// value === 'true'
Also works nicely with React components as you can have the values lazily evaluated by wrapping them in a function:
import cond from 'cond-flow'
const Component = ({ isDisabled, isNew, isLoading }) => (
<>
{cond([
[isLoading, () => <Loading />],
[isNew, () => <Create />],
[isDisabled, null],
])}
</>
)
You can provide a default
fallback which will be returned if no provided conditions are met.
import cond from 'cond-flow'
const value = cond(
[
[false, () => 'false'],
[false, () => 'also false'],
],
{ default: () => 'fallback' },
)
// value === 'fallback'
As all predicates have to be evaluated before the right branch can be chosen, it can have a negative performance impact if you rely on heavy computations. It's best to have simple booleans and resort to Ramda's cond
for complex use cases.
If you find this useful or would like to add features, feel free to clone the repository and open a PR.
FAQs
Elixir style cond for easy javascript control flow
The npm package cond-flow receives a total of 21 weekly downloads. As such, cond-flow popularity was classified as not popular.
We found that cond-flow 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.