
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Converts:
var someModule;
try {
someModule = require('module-that-might-fail');
} catch (e) {
console.log('AARGH! Could not find someModule!');
}
... into:
var requireOr = require('require-or');
var someModule = requireOr('module-that-might-fail', function () {
console.log('AARGH! Could not find someModule!');
});
The callback will be executed synchroniously and a return value will be returned from requireOr as well, allowing:
var someModule = requireOr('some-module', function () {
return require('some-fallback-module');
});
The callback is not mandatory, so if you just want to squelch the error message, you don't need to provide it:
var maybeSomeModule = requireOr('some-module');
Relative paths works as well:
var maybeSomeModule = requireOr('../some-module', function () {
// ...
});
There is multiple other modules trying to solve the same problem.
Both solve the problem of squelching errors, but it does not give you any improvements over vanilla require for the cases where you want to handle the fall back case.
This module is made public under the ISC License.
See the LICENSE file for additional details.
FAQs
require, or...
The npm package require-or receives a total of 6 weekly downloads. As such, require-or popularity was classified as not popular.
We found that require-or 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.