Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
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 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 3 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 the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.