Socket
Socket
Sign inDemoInstall

amd-name-resolver

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amd-name-resolver - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

23

index.js

@@ -0,1 +1,16 @@

module.exports = moduleResolve;
var throwOnRootAccess = true;
exports.resolveModules = function resolveModules(options) {
options = options || {};
if (options.throwOnRootAccess === false) {
throwOnRootAccess = false;
}
return moduleResolve;
}
function moduleResolve(child, name) {

@@ -13,3 +28,7 @@ if (child.charAt(0) !== '.') { return child; }

if (parentBase.length === 0) {
throw new Error('Cannot access parent module of root');
if (throwOnRootAccess) {
throw new Error('Cannot access parent module of root');
} else {
continue;
}
}

@@ -25,3 +44,1 @@ parentBase.pop();

}
module.exports = moduleResolve;

2

package.json
{
"name": "amd-name-resolver",
"version": "0.0.2",
"version": "0.0.3",
"description": "AMD module name resolver algorithm",

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

@@ -5,2 +5,3 @@ 'use strict';

var moduleResolve = require('./index');
var resolveModules = moduleResolve.resolveModules;

@@ -25,2 +26,9 @@ describe('module resolver', function () {

});
it('should not throw if specified', function() {
expect(function() {
var r = resolveModules({ throwOnRootAccess: false });
return r('../../bizz', 'example')
}).to.not.throw(/Cannot access parent module of root/);
});
});
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