Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
node-ensure
Advanced tools
Async module-loading library and protocol for bundlers/loaders targeting isomorphic apps and Node.js.
A simple library that shims asynchronous module loading into Node.js to help with building module bundlers and client-side loaders for isomorphic apps. This library is super slim (read the source) and mainly represents an agreement between developers and users of a particular bundler/loader.
NOTE: This module is not compatible with Browserify. It is for developers that want to split their bundles for the client. For example, see dynapack.
Syntax is inspired by the CommonJS Modules/Async/A proposal.
npm install node-ensure
var ensure = require('node-ensure');
ensure(['superagent', 'react'], function(err) {
var request = require('superagent');
var React = require('react');
// Do the coolest of things.
});
If your bundler needs require.ensure
, do this instead:
require.ensure = require('node-ensure');
require.ensure(['superagent', 'react'], function(err) {
var request = require('superagent');
var React = require('react');
// Do the coolest of things.
});
The returned function takes an array of strings and a callback, in that order (see the example above). The callback takes a single error argument, which usually indicates a network problem or other client-side loader-specific runtime error (it should never receive an error when used in Node.js).
Within the ensure callback, load modules with standard require calls.
This library primarily constitutes an agreement between users and developers of module bundlers and (client-side) loaders. The users agree to the usage instructions supplied above.
Bundlers and/or loaders must adhere to the following:
"browser"
property for replacing
server-only modules with browser-ready counterparts (a la Browserify).require
function passed to a module must have a require.ensure
function.require.ensure
must accept the same arguments as described in Usage.require.ensure
must not access variables via closure unless those variables
are shared by all require.ensure
functions.require.ensure
may access properties
on this
. However, this assumes users have attached node-ensure to require
via
require.ensure = require('node-ensure')
.Happy loading!
MIT
FAQs
Async module-loading library and protocol for bundlers/loaders targeting isomorphic apps and Node.js.
The npm package node-ensure receives a total of 0 weekly downloads. As such, node-ensure popularity was classified as not popular.
We found that node-ensure 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.