Comparing version 0.8.4 to 0.9.0
// modulr.sync.js (c) 2010 Tobie Langel | ||
(function(exports) { | ||
var _factories = {}, | ||
var modulr = {}, | ||
_factories = {}, | ||
_modules = {}, | ||
PREFIX = '__module__', // Poor man's hasOwnProperty | ||
RELATIVE_IDENTIFIER_PATTERN = /^\.\.?\//; | ||
if (__PERF__) { | ||
var _perf = modulr.perf = { | ||
start: Date.now(), | ||
modules: {} | ||
}; | ||
} | ||
function makeRequire(id, main) { | ||
// Find the requirer's dirname from it's id. | ||
var path = id.substring(0, id.lastIndexOf('/') + 1); | ||
function require(identifier) { | ||
if (__PERF__) { var t0 = Date.now(); } | ||
var id = resolveIdentifier(identifier, path), | ||
@@ -17,2 +26,9 @@ key = PREFIX + id, | ||
if (__PERF__) { | ||
var _p = _perf.modules[id] = _perf.modules[id] || { | ||
count: 0, | ||
start: t0 | ||
}; | ||
_p.count++; | ||
} | ||
// Check if this module's factory has already been called. | ||
@@ -28,3 +44,5 @@ if (!mod) { | ||
if (typeof fn === 'string') { | ||
if (__PERF__) { _p.evalStart = Date.now(); } | ||
fn = new Function('require', 'exports', 'module', fn); | ||
if (__PERF__) { _p.evalEnd = Date.now(); } | ||
} | ||
@@ -40,2 +58,3 @@ | ||
fn(r, mod.exports, mod); | ||
if (__PERF__) { _p.end = Date.now(); } | ||
} | ||
@@ -85,2 +104,5 @@ return mod.exports; | ||
exports.require = makeRequire(''); | ||
})(this); | ||
exports.modulr = modulr; | ||
})(this); | ||
if (__PERF__) { modulr.perf.defineStart = Date.now(); } |
// modulr.sync.js (c) 2010 Tobie Langel | ||
(function(exports) { | ||
var _factories = {}, | ||
var modulr = {}, | ||
_factories = {}, | ||
_modules = {}, | ||
PREFIX = '__module__'; // Poor man's hasOwnProperty | ||
if (__PERF__) { | ||
var _perf = modulr.perf = { | ||
start: Date.now(), | ||
modules: {} | ||
}; | ||
} | ||
function require(id) { | ||
@@ -11,2 +19,10 @@ var key = PREFIX + id, | ||
if (__PERF__) { | ||
var _p = _perf.modules[id] = _perf.modules[id] || { | ||
count: 0, | ||
start: Date.now() | ||
}; | ||
_p.count++; | ||
} | ||
if (mod) { return mod.exports; } | ||
@@ -21,3 +37,5 @@ | ||
if (typeof fn === 'string') { | ||
if (__PERF__) { _p.evalStart = Date.now(); } | ||
fn = new Function('require', 'exports', 'module', fn); | ||
if (__PERF__) { _p.evalEnd = Date.now(); } | ||
} | ||
@@ -30,2 +48,3 @@ | ||
fn(require, mod.exports, mod); | ||
if (__PERF__) { _p.end = Date.now(); } | ||
return mod.exports; | ||
@@ -40,2 +59,5 @@ } | ||
exports.require = require; | ||
})(this); | ||
exports.modulr = modulr; | ||
})(this); | ||
if (__PERF__) { modulr.perf.defineStart = Date.now(); } |
@@ -78,3 +78,5 @@ var fs = require('fs'), | ||
buffer.push(this.beforeRequireCall()); | ||
buffer.push(this.renderRequireCall(this._main)); | ||
buffer.push(this.afterRequireCall()); | ||
} | ||
@@ -81,0 +83,0 @@ })(AbstractCollector.prototype); |
@@ -56,2 +56,8 @@ var util = require('util'), | ||
p.beforeRequireCall = beforeRequireCall; | ||
function beforeRequireCall() { | ||
var ast = parser.parse('if (__PERF__) { modulr.perf.defineEnd = modulr.perf.requireMainStart = Date.now(); }'); | ||
return toAstBody(ast); | ||
} | ||
p.renderRequireCall = renderRequireCall; | ||
@@ -62,2 +68,8 @@ function renderRequireCall(m) { | ||
p.afterRequireCall = afterRequireCall; | ||
function afterRequireCall() { | ||
var ast = parser.parse('if (__PERF__) { modulr.perf.requireMainEnd = modulr.perf.end = Date.now(); }'); | ||
return toAstBody(ast); | ||
} | ||
p.renderRuntime = renderRuntime; | ||
@@ -64,0 +76,0 @@ function renderRuntime() { |
@@ -59,2 +59,3 @@ var DEV = 'dev', | ||
this.setDevConstant(clonedConsts); | ||
this.setPerfConstant(clonedConsts); | ||
@@ -86,2 +87,7 @@ result.lazyEval = lazyEval; | ||
p.setPerfConstant = setPerfConstant; | ||
function setPerfConstant(constants) { | ||
constants.__PERF__ = this.config.instrumentPerformance ? true : false; | ||
} | ||
p.getEnv = function() { | ||
@@ -88,0 +94,0 @@ var config = this.config, |
@@ -57,3 +57,3 @@ var util = require('util'), | ||
return Object.keys(constants).map(function(k) { | ||
return 'var ' + k + ' = ' + constants[k] + ';'; | ||
return 'var ' + k + ' = ' + JSON.stringify(constants[k]) + ';'; | ||
}).join('\n'); | ||
@@ -106,2 +106,7 @@ } | ||
p.beforeRequireCall = beforeRequireCall; | ||
function beforeRequireCall() { | ||
return 'if (__PERF__) { modulr.perf.defineEnd = modulr.perf.requireMainStart = Date.now(); }\n'; | ||
} | ||
p.renderRequireCall = renderRequireCall; | ||
@@ -112,2 +117,7 @@ function renderRequireCall(m) { | ||
p.afterRequireCall = afterRequireCall; | ||
function afterRequireCall() { | ||
return 'if (__PERF__) { modulr.perf.requireMainEnd = modulr.perf.end = Date.now(); }\n'; | ||
} | ||
p.renderRuntime = renderRuntime; | ||
@@ -114,0 +124,0 @@ function renderRuntime() { |
@@ -5,5 +5,5 @@ { | ||
"main": "./main", | ||
"version": "0.8.4", | ||
"version": "0.9.0", | ||
"dependencies": { | ||
"module-grapher": ">=0.10.3", | ||
"module-grapher": ">=0.10.4", | ||
"uglify-js": ">=1.0.7" | ||
@@ -37,3 +37,4 @@ }, | ||
"node": "*" | ||
} | ||
} | ||
}, | ||
"optionalDependencies": {} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39014
1084
Updatedmodule-grapher@>=0.10.4