express中的flash到底是起什么作用,现在不太理解。请指教
function _flash(type, msg) { 59 if (this.session === undefined) throw Error(‘req.flash() requires sessions’); 60 var msgs = this.session.flash = this.session.flash || {}; 61 if (type && msg) { 62 // util.format is available in Node.js 0.6+ 63 if (arguments.length > 2 && format) { 64 var args = Array.prototype.slice.call(arguments, 1); 65 msg = format.apply(undefined, args); 66 } 67 return (msgs[type] = msgs[type] || []).push(msg); 68 } else if (type) { 69 var arr = msgs[type]; 70 delete msgs[type]; 71 return arr || []; 72 } else { 73 this.session.flash = {}; 74 return msgs; 75 } 76 }
主要代码就在上面,我没有用过,不过看情况就是做了一个数据map,然后类似按顺序存。我没用过,