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.
feature-detect
Advanced tools
This library is meant to provide feature detection support for Node.js or Io.js compatible environments. It is not intended to provide feature detection support in browser environments, for which there already are numerous alternatives.
npm install --save feature-detect
To detect features at install time, put an install
script similar to the following in package.json
:
{ scripts:
{ "install": "feature-detect generators" }
}
In the example above, the feature-detect
executable will load the module generators
. The module is expected to export a list of tests, like so:
exports.feature = 'Generators'
exports.tests =
[ 'generator syntax'
, function() {
return function *() { yield true }
}
]
]
When running npm install
in an environment that supports generators, nothing will happen, but if generators aren't supported, the installation will fail and you should see output like the following:
WeakMap is not supported in this environment
├ ✘ basic functionality WeakMap is not defined
├ ✘ constructor arguments WeakMap is not defined
├ ✘ WeakMap.prototype.set returns this WeakMap is not defined
├ ✘ WeakMap.prototype.delete WeakMap is not defined
└ ✘ Support frozen objects as keys WeakMap is not defined
While installation time detection is recommended, it is possible to do runtime detection:
var detect = require('feature-detect')
var result = detect(
{ feature: 'WeakMap'
, tests:
[ [ 'basic functionality', function() {
var key = {};
var weakmap = new WeakMap();
weakmap.set(key, 123);
return weakmap.has(key) && weakmap.get(key) === 123;
} ]
]
}
)
result.success? console.log('WeakMap supported!') : console.error('No WeakMap!')
License: MIT
FAQs
Feature detection library for node environments.
We found that feature-detect 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.