var fs = require('fs');
fs.readFile('ejsPage.ejs', 'utf-8', function(error, data){
response.writeHead(200, {'Content-Type': 'text-html'});
response.end(ejs.render(data));
});
var fs = require('fs');
fs.readFile('ejsPage.ejs', 'utf-8', function(error, data){
response.writeHead(200, {'Content-Type': 'text-html'});
response.end(ejs.render(data));
});
var async = require('async');
var files = ['Txt1.txt', 'Txt2.txt','Txt3.txt'];
async.forEach(files, function(item, index){
console.log(item);
});
async.map(files, fs.readFile, function(error , results){
console.log(results);
});
//순차실행
async.series([
function (callback){
console.log("11111111");
callback(null, 1);
},
function(callback){
console.log("22222222");
callback(null, 2);
}
], function(error, result){
console.log("333333", result);
});
//동시실행
async.parallel([
function (callback){
console.log("11111111");
callback(null, 1);
},
function(callback){
console.log("22222222");
callback(null, 2);
}
], function(error, result){
console.log("333333", result);
});
460 P 참고
var DummyDB = (function(){
var DummyDB = {};
var storage = [];
var count = 1;
DummyDB.get = function(id){
if(id){
id = (typeof id == 'string') ? Number(id):id;
for(var i in storage) if (storage[i].id == id){
return storage[i];
}
}
else{
return storage;
}
};
DummyDB.insert = function(data){
data.id = count++;
storage.push(data);
return data;
};
DummyDB.remove = function(id){
//변수 가공
id = (typeof id == 'string') ? Number(id) : id;
for(var i in storage) if (storage[i].id == id){
storage.splice(i, 1);
return true;
}
return false;
};
return DummyDB;
})();
json stringify (0) | 2017.11.18 |
---|---|
tableToExcel (0) | 2017.08.18 |
promise (0) | 2017.03.12 |
json data roop (0) | 2012.02.29 |
DOM (0) | 2012.02.17 |