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. Written in ES6 (ES2015) as a CommonJS module.
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(foo.bar).isAnyOf(
'value_a',
'value_b',
'value_c',
'value_d',
'value_e'
)) {
// do something
}
Allege exposes different functions based on what you're trying to compare. If you pass in one argument, you can then call any of the Single Input Methods. However, if you pass in multiple arguments, you can then call any of the Multiple Input Methods.
Each of these commands are available as below:
To use these methods, call Allege with just a single argument, like so: allege(foo)
. Then, these methods
will be available:
bool
isAnyOf(possibility1, ..., possibilityN)Determines whether foo
is referentially equal (===
) to any of the possibility
items.
allege(5).isAnyOf(1, 2, 3, 4, 5, 6);
// --> true
allege('hi').isAnyOf('hello', 'good morning', 'sup');
// --> false
bool
isNoneOf(possibility1, ..., possibilityN)Determines whether foo
is referentially unequal (!==
) to all of the possibility
items.
allege(5).isNoneOf(1, 2, 3, 4);
// --> true
allege(5).isNoneOf(1, 2, 3, 4, 5);
// --> false
bool
isAllOf(possibility1, ..., possibilityN)Determines whether foo
is referentially equal (===
) to all of the possibility
items.
allege(5).isAllOf(5, 5, 5);
// --> true
allege(5).isAllOf(5, 5, 4);
// --> false
To use these methods, call Allege with more than one argument, like so: allege(foo, bar, baz, quux)
. Then, these
methods will be available:
bool
areAll(possibility)Determines whether all input
s are referentially equal (===
) to the possibility
item.
allege(5, 5, 5, 5).areAll(5);
// --> true
allege(5, 5, 5, 5).areAll(4);
// --> false
bool
areAllNot(possibility)Determines whether all input
s are referentially unequal (!==
) to the possibility
item.
allege(5, 5, 5, 5).areAllNot(4);
// --> true
allege(5, 5, 5, 5).areAllNot(5);
// --> false
Grab this module from npm
with the following command:
npm install allege
This module follows SemVer.
MIT. See the LICENSE
file for more details.
There's not much by way of tests right now. More tests will come soon.
The files that reside in the lib/
directory are transpiled from ES6 to ES5. The original source
files reside in the src/
directory. These can be built with the following command:
npm run transpile-to-es5
FAQs
Make complex conditionals easier to read and write
The npm package allege receives a total of 17 weekly downloads. As such, allege popularity was classified as not popular.
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.