Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "use", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "DRY version of require()", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -21,9 +21,25 @@ Use.js | ||
'path', | ||
'stream' | ||
'stream', | ||
'xregexp#XRegExp', | ||
'./helper' | ||
)); | ||
util.debug('Easy as pie...'); | ||
XRegExp.replace( | ||
'x-key-lime', | ||
XRegExp('\\b\\w', 'g'), | ||
function(match) { | ||
return match.toUpperCase(); | ||
} | ||
); | ||
helper.doSomethingGrand(); | ||
``` | ||
Warning: This module does not work in strict mode. Only enable strict mode, if you need it, after the eval statement. | ||
### Warning ### | ||
This module does not work in strict mode. Only enable strict mode, if you need it, *after* the eval statement. | ||
17
use.js
var util = require('util'); | ||
var path = require('path'); | ||
@@ -8,3 +9,17 @@ exports = module.exports = function use(moduleNames) { | ||
moduleNames.forEach(function (m) { | ||
script += util.format('var %s = require("%s"); ', m, m); | ||
var tokens = m.split('#'); | ||
if (tokens.length === 2) { | ||
var moduleName = tokens[0]; | ||
var className = tokens[1]; | ||
script += util.format( | ||
'var %s = require("%s").%s', | ||
className, moduleName, className) | ||
} | ||
else { | ||
script += util.format( | ||
'var %s = require("%s"); ', | ||
path.basename(m), m); | ||
} | ||
}) | ||
@@ -11,0 +26,0 @@ |
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
2144
33
45