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.
A one-liner to check if a property is set (not null, undefined or empty string).
A one-liner to check if a property is set (not null
, undefined
or an empty
string).
Run the following command to make this package available in your project:
npm install is-it-set --save
Import this package into your script like this:
const isSet = require('is-it-set');
Now you can run isSet
on any input:
/*
* Empty strings, `null` and `undefined` all return `false`
*/
isSet('') // => false
isSet(null) // => false
isSet(undefined) // => false
/*
* Any other input returns `true`
*/
isSet(0) // => true
isSet(-1) // => true
isSet(' ') // => true
isSet(false) // => true
isSet('Hello') // => true
isSet(Infinity) // => true
isSet(Date) // => true
JavaScript has some opinions on what should be considered falsy, and that's great for developer convenience when dealing with variable data.
However, sometimes the only values that should not pass a test (like an if()
)
should be data types that purposefully mean "no data" -- null
, undefined
and
the empty string (''
). Empty strings are often used as a no-data indicator in
JSON documents.
function squareNumber(input) {
/**
* A simple check to make sure there's data to work with
*/
if (isSet(input)) {
return input * input;
} else {
throw new ReferenceError('No input given');
}
}
This repo follows SemVer
To run the tests for this package, clone the repo and run the following in your terminal:
npm install
npm test
FAQs
A one-liner to check if a property is set (not null, undefined or empty string).
The npm package is-it-set receives a total of 7 weekly downloads. As such, is-it-set popularity was classified as not popular.
We found that is-it-set 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.