nodejs 模块变量 应用
exports.allcodeandname=(function(){ var fs = require('fs'); var data = fs.readFileSync(__dirname+'/areacode',{encoding:'utf-8'}); var lines = (data + '').split('\n'); 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 } })();