Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loader.js

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loader.js - npm Package Compare versions

Comparing version 3.5.0 to 3.6.0

3

loader.js

@@ -81,2 +81,5 @@ var loader, define, requireModule, require, requirejs;

} else {
if (loader.wrapModules) {
this.callback = loader.wrapModules(this.name, this.callback);
}
var result = this.callback.apply(this, reifiedDeps);

@@ -83,0 +86,0 @@ if (!(this.hasExportsAsDep && result === undefined)) {

2

package.json
{
"name": "loader.js",
"version": "3.5.0",
"version": "3.6.0",
"description": "loader.js =========",

@@ -5,0 +5,0 @@ "main": "loader.js",

@@ -24,2 +24,18 @@ loader.js [![Build Status](https://travis-ci.org/ember-cli/loader.js.png?branch=master)](https://travis-ci.org/ember-cli/loader.js)

## wrapModules
It is possible to hook loader to augment or transform the loaded code. `wrapModules` is an optional method on the loader that is called as each module is originally loaded. `wrapModules` must be a function of the form `wrapModules(name, callback)`. The `callback` is the original AMD callback. The return value of `wrapModules` is then used in subsequent requests for `name`
This functionality is useful for instrumenting code, for instance in code coverage libraries.
```
loader.wrapModules = function(name, callback) {
if (shouldTransform(name) {
return myTransformer(name, callback);
}
}
return callback;
};
```
## Tests

@@ -26,0 +42,0 @@

@@ -660,1 +660,17 @@ /*globals newDefine:false, newLoader:false, newRequire:false*/

});
test('wrapModules is called when present', function() {
var fooCalled = 0;
var annotatorCalled = 0;
loader.wrapModules = function(name, callback) {
annotatorCalled++;
return callback;
};
define('foo', [], function() {
fooCalled++;
});
equal(annotatorCalled, 0);
require('foo');
equal(annotatorCalled, 1);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc