nodejsモジュール変数応用
1840 ワード
exports.allcodeandname=(function(){
var fs = require('fs');
var data = fs.readFileSync(__dirname+'/areacode',{encoding:'utf-8'});
var lines = (data + '').split('
');
var allcodeandname={};
lines.forEach(function(line){
var infos=line.split(' ');
allcodeandname[infos[0]]=infos[1];
});
return allcodeandname;
})()
var analysicstatus= (function(){
var _value = 0;//
function set(num){
_value=num;
}
function get(){
return _value;
}
return {
set:set,
get:get
}
})();