
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
NOTE: The package what-is was renamed to wots. Please, consider installing the renamed version.
The library was written as a simple coding exercise, but then appeared useful to share :wink:
npm install --save what-is
and then
var whatis = require('what-is');
// ...
if (whatis(myNotAlwaysNumericVariable) === 'NaN') {
// do some stuff
}
whatis() function returns reasonable type names for tested values:
| description | input | result |
|---|---|---|
| null | null | 'null' |
| undefined | undefined | 'undefined' |
| strings | 'foo' | 'string' |
'' | 'string' | |
['Hello', 'world!'].join(' ') | 'string' | |
new String() | 'string' | |
| numbers | 5 | 'number' |
parseInt(42) | 'number' | |
new Number('3') | 'number' | |
NaN | 'NaN' | |
Infinity | 'Infinity' | |
1 / -0 | 'Infinity' | |
| boolean values | false | 'boolean' |
!!nonEmptyVariable | 'boolean' | |
new Boolean('0') | 'boolean' | |
| regular expressions | /^test$/g | 'regexp' |
new RegExp('needle', 'i') | 'regexp' | |
| arrays | ['foo', 'bar', 'baz'] | 'array' |
new Array(10) | 'array' | |
| objects | { foo: 'bar'} | 'object' |
{} | 'object' | |
new Object() | 'object' | |
Object.create(null) | throws error (to be fixed) | |
| functions | function () {} | 'function' |
new Function('return null') | 'function' | |
| date objects | new Date() | 'date' |
| errors | new Error('error!') | 'error' |
new TypeError('type error!') | 'error' | |
| arguments objects | (function(){return arguments;})() | 'arguments' |
| class constructors | new MyClass() | 'myclass' |
new Buffer() | 'buffer' | |
new XMLHttpRequest() | 'xmlhttprequest' | |
| promises | new Promise(function() {}) | 'promise' |
Promise.resolve('data') | 'promise' | |
Promise.reject(new Error('Oop!')) | 'promise' |
Note: for more examples see test file
FAQs
A very simple "typeof" detection
We found that what-is 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.