nc.js icon indicating copy to clipboard operation
nc.js copied to clipboard

Supports for remote modules (Sync/Async).

Open Andy5972 opened this issue 8 years ago • 0 comments

Supports for remote modules (Sync/Async). 这个功能实现了吗? var http = require('http') , vm = require('vm') , concat = require('concat-stream') , async = require('async');

function http_require(url, callback) { http.get(url, function(res) { // console.log('fetching: ' + url) res.setEncoding('utf8'); res.pipe(concat({encoding: 'string'}, function(data) { callback(null, vm.runInThisContext(data)); })); }) }

urls = [ 'http://example.com/nodejsmodules/myModule1.js', 'http://example.com/nodejsmodules/myModule2.js', 'http://example.com/nodejsmodules/myModule3.js', ]

async.map(urls, http_require, function(err, results) { // results is an array of values returned by runInThisContext // the rest of your program logic }); 网上找的nodejs 的代码 nc.js 这种应该怎么做

Andy5972 avatar Oct 12 '16 08:10 Andy5972