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.
@kyleshevlin/kase
Advanced tools
A simple, type-safe pattern-ish matching function.
const result = kase(person.age)
.when(1, () => "You're just a baby!")
.when(
x => x < 18,
() => "You've gotten so big!"
)
.when(
x => x < 65,
() => "So how's work?"
)
.when(
x => x < 90,
age => `Holy smokes, You don't look a day over ${age - 10}!`
)
.otherwise(() => 'Uhh, do you even have a pulse?')
Note: It might be to your benefit to take a look at the types in kase.ts
.
kase
function kase(input) {}
kase
takes an input
which is any value, and stores it to be compared to the pattern
s passed to the when
and otherwise
methods.
when
function when(pattern, callback) {}
when
receives a pattern
to compare to the input
. A pattern
can either be a value of the same type as input
, or a predicate function that receives the input
as an argument. If the pattern
argument is a value, it is matched strictly against the input
with ===
.
when
also receives a callback
function which should return the desired result should a match be found. The first when
to match is the result of the kase
chain.
otherwise
function otherwise(callback) {}
otherwise
is how we provide a default result. It receives a callback
exactly like when
. otherwise
will return the result of the callback
as the result of the entire chain.
end
function end() {}
If no otherwise
is provided, end
is necessary to complete the chain and return the result. Like so:
const result = kase(Math.random())
.when(
x => x <= 0.33,
() => 'low'
)
.when(
x => x <= 0.67,
() => 'mid'
)
.when(
x => x <= 0.99,
() => 'high'
)
.end() // would return `undefined` in the cases where x is > .99
FAQs
A simple type-safe pattern matcher
The npm package @kyleshevlin/kase receives a total of 0 weekly downloads. As such, @kyleshevlin/kase popularity was classified as not popular.
We found that @kyleshevlin/kase 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.