Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Make complex conditionals easier to read and write.
Sometimes, if
statements can get very complex. For example:
if (foo.bar === 'value_a' || foo.bar === 'value_b' || foo.bar === 'value_c' || foo.bar === 'value_d' || foo.bar === 'value_e') {
// do something
}
With Allege, you can simplify your if
like so:
if (allege.that(foo.bar).isIn(
'value_a',
'value_b',
'value_c',
'value_d',
'value_e'
)) {
// do something
}
Allege exposes different functions based on what you're trying to compare.
To use these methods, call allege.that()
with just a single argument,
like so: allege.that(foo)
. Then, these methods will be available:
isIn(possibility1, ..., possibilityN) -> boolean
Determines whether foo
is referentially equal (===
) to any of the possibility
items.
allege.that(5).isIn(1, 2, 3, 4, 5, 6);
// --> true
allege.that('hi').isIn('hello', 'good morning', 'sup');
// --> false
isNotIn(possibility1, ..., possibilityN) -> boolean
Determines whether foo
is referentially unequal (!==
) to all of the possibility
items.
allege.that(5).isNotIn(1, 2, 3, 4);
// --> true
allege.that(5).isNotIn(1, 2, 3, 4, 5);
// --> false
To use these methods, call allege.these()
with more than one argument,
like so: allege.these(foo, bar, baz, quux)
. Then, these methods will be available:
areAll(possibility) -> boolean
Determines whether all input
s are referentially equal (===
) to the possibility
item.
allege.these(5, 5, 5, 5).areAll(5);
// --> true
allege.these(5, 4, 5, 4).areAll(4);
// --> false
areAllNot(possibility) -> boolean
Determines whether all input
s are referentially unequal (!==
) to the possibility
item.
allege.these(5, 5, 5, 5).areAllNot(4);
// --> true
allege.these(5, 5, 5, 5).areAllNot(5);
// --> false
Grab this module from npm
with the following command:
yarn add allege
Then you can use it in your project like so:
import allege from 'allege';
if (allege.that(5).isNotIn(1,2,3)) {
// do something
}
// or:
import { that, these } from 'allege';
if (that(5).isNotIn(1,2,3)) {
// do something
}
This module follows SemVer.
MIT. See the LICENSE
file for more details.
You can execute the existing test suite by running the following in your terminal:
yarn install
yarn test
The code that resides in the index.js
file is transpiled from an ES6 source. The original source
files reside in the src/
directory. These can be built with the following command:
yarn build
FAQs
Make complex conditionals easier to read and write
We found that allege 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.