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.
Require modules lazily
$ npm install --save lazy-req
// pass in `require` or a custom require function
const lazyReq = require('lazy-req')(require);
const _ = lazyReq('lodash');
// Where you would normally do
_.isNumber(2);
// You now instead call it as a function
_().isNumber(2);
// It's cached on consecutive calls
_().isString('unicorn');
// Extract lazy variations of the props you need
const members = lazyReq('lodash')('isNumber', 'isString');
// Useful when using destructuring assignment in ES2015
const {isNumber, isString} = lazyReq('lodash')('isNumber', 'isString');
// Works out of the box for functions and regular properties
const stuff = lazyReq('./math-lib')('sum', 'PHI');
console.log(stuff.sum(1, 2)); // => 3
console.log(stuff.PHI); // => 1.618033
If you use Node.js 6 or later, you can take advantage of ES2015 proxies and don't need to call it as a function.
const lazyReq = require('lazy-req').proxy(require);
const _ = lazyReq('lodash');
// No need to call it as a function but still lazily required
_.isNumber(2);
MIT © Sindre Sorhus
FAQs
Require modules lazily
The npm package lazy-req receives a total of 102,084 weekly downloads. As such, lazy-req popularity was classified as popular.
We found that lazy-req 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.