Socket
Socket
Sign inDemoInstall

browser-amd

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-amd - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

bower.json

51

amd.js

@@ -5,3 +5,5 @@

var definitions = {},
on = {};
on = {},
functionSignature = /^function[^(]+\((.*?)\)/,
waitingFor = null;

@@ -15,3 +17,3 @@ function trim (value) {

factory = dependencies;
if( typeof id === 'array' ) {
if( id instanceof Array ) {
dependencies = id;

@@ -32,9 +34,16 @@ id = undefined;

if( !dependencies ) {
dependencies = factory.toString().match(/^function[^(]+\((.*?)\)/)[1].split(',').map(trim);
dependencies = factory.toString().match(functionSignature)[1].split(',').map(trim);
}
require(dependencies, function () {
if( id === undefined && waitingFor ) {
id = waitingFor;
waitingFor = null;
}
var module = { exports : {} };
require.call({ locals: { module: module, exports: module.exports } }, dependencies, function () {
var result = factory.apply(arguments);
if( id ) {
definitions[id] = result;
definitions[id] = result === undefined ? module.exports : result;
if( on[id] ) {

@@ -64,2 +73,5 @@ on[id].forEach(function (listener) {

script.src = libUrl(dependence);
script.onload = function () {
waitingFor = dependence;
};
document.head.appendChild(script);

@@ -73,2 +85,22 @@ }

function require (dependencies, callback) {
var locals = this === root ? {} : this.locals || {};
if( typeof dependencies === 'string' ) {
if( callback === undefined ) {
return locals[dependencies] || definitions[dependencies];
}
dependencies = [dependencies];
} else if( typeof dependencies === 'function' ) {
callback = dependencies;
dependencies = ['require', 'exports', 'module'];
}
if( !(dependencies instanceof Array) ) {
throw new Error('missing list of dependencies');
}
if( typeof callback !== 'function' ) {
throw new Error('missing callback');
}
var resolutions = [],

@@ -78,5 +110,5 @@ resolved = [];

dependencies.forEach(function (id, i, dependencies) {
if( definitions[id] ) {
if( locals[i] || definitions[id] ) {
resolutions[i] = definitions[id];
resolutions[i] = locals[i] || definitions[id];
resolved[i] = true;

@@ -93,2 +125,3 @@

});
loadLib(id);

@@ -103,2 +136,6 @@ }

require.toUrl = libUrl;
definitions.require = require;
root.define = define;

@@ -105,0 +142,0 @@ root.require = require;

2

package.json
{
"name": "browser-amd",
"version": "1.0.0",
"version": "1.0.1",
"description": "simple browser amd loader",

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

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