diff --git a/lib/flash.js b/lib/flash.js index a278bc1..24555ae 100644 --- a/lib/flash.js +++ b/lib/flash.js @@ -11,11 +11,11 @@ var isArray = require('util').isArray; * @return {Function} * @api public */ -module.exports = function flash(options) { +module.exports = function flash (options) { options = options || {}; var safe = (options.unsafe === undefined) ? true : !options.unsafe; - - return function(req, res, next) { + + return function (req, res, next) { if (req.flash && safe) { return next(); } req.flash = _flash; next(); @@ -56,7 +56,7 @@ module.exports = function flash(options) { * @return {Array|Object|Number} * @api public */ -function _flash(type, msg) { +function _flash (type, msg) { if (this.session === undefined) throw Error('req.flash() requires sessions'); var msgs = this.session.flash = this.session.flash || {}; if (type && msg) { @@ -64,8 +64,8 @@ function _flash(type, msg) { if (arguments.length > 2 && format) { var args = Array.prototype.slice.call(arguments, 1); msg = format.apply(undefined, args); - } else if (isArray(msg)) { - msg.forEach(function(val){ + } else if (Array.isArray(msg)) { + msg.forEach(function (val) { (msgs[type] = msgs[type] || []).push(val); }); return msgs[type].length;