render_and_script
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,14 +0,25 @@ | ||
var jsdom = require('jsdom'), | ||
async = require('async'); | ||
var path = require('path'), | ||
jsdom = require('jsdom'), | ||
async = require('async'), | ||
_ = require('underscore'); | ||
// renderして、クライアントサイドのスクリプトを実行してから返す | ||
var renderAndScript = function (view, options, script) { | ||
var renderAndScript = function (view, options, scripts) { | ||
var self = this; | ||
// options省略処理 | ||
if (typeof options == 'function') { | ||
script = options; | ||
options = {}; | ||
} | ||
scripts = scripts || []; | ||
// 実行する関数のリスト | ||
var scriptFns = _.select(scripts, function (script) { | ||
return typeof script == 'function'; | ||
}); | ||
// 関数実行の前に読み込むライブラリのリスト | ||
var scriptFiles = _.select(scripts, function (script) { | ||
return typeof script == 'string'; | ||
}); | ||
scriptFiles = _.map(scriptFiles, function (scriptFile) { | ||
return path.join(__dirname + '/../', scriptFile); | ||
}); | ||
async.waterfall([function (next) { | ||
@@ -19,8 +30,14 @@ // render engineによるレンダリング | ||
// レンダリング結果をもとにjsdom環境を作る | ||
jsdom.env(html, [], next); | ||
jsdom.env(html, scriptFiles, next); | ||
}, function(window, next) { | ||
// scriptを実行 実行後のwindowを次へ渡す | ||
script(window, function (err) { | ||
async.forEachSeries(scriptFns, function (script, next) { | ||
script(window, function (err) { | ||
next(err); | ||
}); | ||
}, function (err) { | ||
next(err, window); | ||
}); | ||
}, function(window, next) { | ||
@@ -27,0 +44,0 @@ // windowからhtmlを再度取り出して、send |
{ | ||
"name": "render_and_script", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"scripts": { | ||
@@ -9,3 +9,4 @@ "start": "node app" | ||
"jsdom": "*", | ||
"async": "*" | ||
"async": "*", | ||
"underscore": "*" | ||
}, | ||
@@ -12,0 +13,0 @@ "devDependencies": { |
Floating dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
4227
6
73
3
4
2
1
+ Addedunderscore@*
+ Addedunderscore@1.13.6(transitive)