diff --git a/package.json b/package.json index b60e932d..7072d0dd 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "commander": "2.9.0", "event-stream": "3.3.2", "express": "4.13.4", - "lodash": "~2.4.1", + "lodash": "4.5.0", "mkdirp": "0.5.1", "moment": "2.11.2", "read": "1.0.7", diff --git a/src/clientManager.js b/src/clientManager.js index 624dd9d7..f006f848 100644 --- a/src/clientManager.js +++ b/src/clientManager.js @@ -110,7 +110,7 @@ ClientManager.prototype.removeUser = function(name) { ClientManager.prototype.autoload = function(/* sockets */) { var self = this; setInterval(function() { - var loaded = _.pluck( + var loaded = _.map( self.clients, "name" ); @@ -135,4 +135,3 @@ ClientManager.prototype.autoload = function(/* sockets */) { }); }, 1000); }; - diff --git a/src/models/network.js b/src/models/network.js index 87556275..0b641177 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -46,8 +46,8 @@ Network.prototype.export = function() { "commands" ]); network.nick = (this.irc || {}).me; - network.join = _.pluck( - _.where(this.channels, {type: "channel"}), + network.join = _.map( + _.filter(this.channels, {type: "channel"}), "name" ).join(","); return network; diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index 9c1879ce..c910b716 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -10,7 +10,7 @@ module.exports = function(network, chan, cmd, args) { var irc = network.irc; irc.notice(args[0], message); - var targetChan = _.findWhere(network.channels, {name: args[0]}); + var targetChan = _.find(network.channels, {name: args[0]}); if (typeof targetChan === "undefined") { message = "{to " + args[0] + "} " + message; targetChan = chan; diff --git a/src/plugins/irc-events/kick.js b/src/plugins/irc-events/kick.js index a826450d..b4d1c997 100644 --- a/src/plugins/irc-events/kick.js +++ b/src/plugins/irc-events/kick.js @@ -5,7 +5,7 @@ module.exports = function(irc, network) { var client = this; irc.on("kick", function(data) { var from = data.nick; - var chan = _.findWhere(network.channels, {name: data.channel}); + var chan = _.find(network.channels, {name: data.channel}); var mode = chan.getMode(from); if (typeof chan === "undefined") { @@ -15,7 +15,7 @@ module.exports = function(irc, network) { if (data.client === irc.me) { chan.users = []; } else { - chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client})); + chan.users = _.without(chan.users, _.find(chan.users, {name: data.client})); } client.emit("users", { diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index 9a844beb..31c84934 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -29,7 +29,7 @@ module.exports = function(irc, network) { } var self = data.to.toLowerCase() === irc.me.toLowerCase(); - var chan = _.findWhere(network.channels, {name: self ? data.from : data.to}); + var chan = _.find(network.channels, {name: self ? data.from : data.to}); if (typeof chan === "undefined") { return; } diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 18b48e93..9ac503fc 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -15,7 +15,7 @@ module.exports = function(irc, network) { target = data.from; } - var chan = _.findWhere(network.channels, {name: target}); + var chan = _.find(network.channels, {name: target}); if (typeof chan === "undefined") { chan = new Chan({ type: Chan.Type.QUERY, diff --git a/src/plugins/irc-events/mode.js b/src/plugins/irc-events/mode.js index 0d462f0b..be4868eb 100644 --- a/src/plugins/irc-events/mode.js +++ b/src/plugins/irc-events/mode.js @@ -4,7 +4,7 @@ var Msg = require("../../models/msg"); module.exports = function(irc, network) { var client = this; irc.on("mode", function(data) { - var chan = _.findWhere(network.channels, {name: data.target}); + var chan = _.find(network.channels, {name: data.target}); if (typeof chan !== "undefined") { setTimeout(function() { irc.write("NAMES " + data.target); diff --git a/src/plugins/irc-events/names.js b/src/plugins/irc-events/names.js index 1fd2c1b0..11e139b9 100644 --- a/src/plugins/irc-events/names.js +++ b/src/plugins/irc-events/names.js @@ -4,7 +4,7 @@ var User = require("../../models/user"); module.exports = function(irc, network) { var client = this; irc.on("names", function(data) { - var chan = _.findWhere(network.channels, {name: data.channel}); + var chan = _.find(network.channels, {name: data.channel}); if (typeof chan === "undefined") { return; } diff --git a/src/plugins/irc-events/nick.js b/src/plugins/irc-events/nick.js index fc65c4f2..aff4a2ce 100644 --- a/src/plugins/irc-events/nick.js +++ b/src/plugins/irc-events/nick.js @@ -24,7 +24,7 @@ module.exports = function(irc, network) { }); } network.channels.forEach(function(chan) { - var user = _.findWhere(chan.users, {name: data.nick}); + var user = _.find(chan.users, {name: data.nick}); if (typeof user === "undefined") { return; } diff --git a/src/plugins/irc-events/notice.js b/src/plugins/irc-events/notice.js index da9d3fe3..391ebda8 100644 --- a/src/plugins/irc-events/notice.js +++ b/src/plugins/irc-events/notice.js @@ -9,7 +9,7 @@ module.exports = function(irc, network) { target = data.from; } - var chan = _.findWhere(network.channels, {name: target}); + var chan = _.find(network.channels, {name: target}); if (typeof chan === "undefined") { chan = network.channels[0]; } diff --git a/src/plugins/irc-events/part.js b/src/plugins/irc-events/part.js index d4c0bb1c..f64ac4c2 100644 --- a/src/plugins/irc-events/part.js +++ b/src/plugins/irc-events/part.js @@ -4,7 +4,7 @@ var Msg = require("../../models/msg"); module.exports = function(irc, network) { var client = this; irc.on("part", function(data) { - var chan = _.findWhere(network.channels, {name: data.channels[0]}); + var chan = _.find(network.channels, {name: data.channels[0]}); if (typeof chan === "undefined") { return; } @@ -16,7 +16,7 @@ module.exports = function(irc, network) { chan: chan.id }); } else { - var user = _.findWhere(chan.users, {name: from}); + var user = _.find(chan.users, {name: from}); chan.users = _.without(chan.users, user); client.emit("users", { chan: chan.id, diff --git a/src/plugins/irc-events/quit.js b/src/plugins/irc-events/quit.js index 46322a10..da56dc67 100644 --- a/src/plugins/irc-events/quit.js +++ b/src/plugins/irc-events/quit.js @@ -6,7 +6,7 @@ module.exports = function(irc, network) { irc.on("quit", function(data) { network.channels.forEach(function(chan) { var from = data.nick; - var user = _.findWhere(chan.users, {name: from}); + var user = _.find(chan.users, {name: from}); if (typeof user === "undefined") { return; } diff --git a/src/plugins/irc-events/topic.js b/src/plugins/irc-events/topic.js index 1b54c249..879a890f 100644 --- a/src/plugins/irc-events/topic.js +++ b/src/plugins/irc-events/topic.js @@ -4,7 +4,7 @@ var Msg = require("../../models/msg"); module.exports = function(irc, network) { var client = this; irc.on("topic", function(data) { - var chan = _.findWhere(network.channels, {name: data.channel}); + var chan = _.find(network.channels, {name: data.channel}); if (typeof chan === "undefined") { return; } diff --git a/src/plugins/irc-events/whois.js b/src/plugins/irc-events/whois.js index 7e014368..38374146 100644 --- a/src/plugins/irc-events/whois.js +++ b/src/plugins/irc-events/whois.js @@ -8,7 +8,7 @@ module.exports = function(irc, network) { if (data === null) { return; } - var chan = _.findWhere(network.channels, {name: data.nickname}); + var chan = _.find(network.channels, {name: data.nickname}); if (typeof chan === "undefined") { chan = new Chan({ type: Chan.Type.QUERY, diff --git a/src/server.js b/src/server.js index fd1b29fd..593e8671 100644 --- a/src/server.js +++ b/src/server.js @@ -77,12 +77,10 @@ function index(req, res, next) { require("../package.json"), config ); + var template = _.template(file); res.setHeader("Content-Type", "text/html"); res.writeHead(200); - res.end(_.template( - file, - data - )); + res.end(template(data)); }); }