Merge pull request #38 from xPaw/lodash

Update lodash
This commit is contained in:
Alistair McKinlay 2016-02-21 15:31:44 +00:00
commit b2625aebae
16 changed files with 20 additions and 23 deletions

View file

@ -32,7 +32,7 @@
"commander": "2.9.0", "commander": "2.9.0",
"event-stream": "3.3.2", "event-stream": "3.3.2",
"express": "4.13.4", "express": "4.13.4",
"lodash": "~2.4.1", "lodash": "4.5.0",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
"moment": "2.11.2", "moment": "2.11.2",
"read": "1.0.7", "read": "1.0.7",

View file

@ -110,7 +110,7 @@ ClientManager.prototype.removeUser = function(name) {
ClientManager.prototype.autoload = function(/* sockets */) { ClientManager.prototype.autoload = function(/* sockets */) {
var self = this; var self = this;
setInterval(function() { setInterval(function() {
var loaded = _.pluck( var loaded = _.map(
self.clients, self.clients,
"name" "name"
); );
@ -135,4 +135,3 @@ ClientManager.prototype.autoload = function(/* sockets */) {
}); });
}, 1000); }, 1000);
}; };

View file

@ -46,8 +46,8 @@ Network.prototype.export = function() {
"commands" "commands"
]); ]);
network.nick = (this.irc || {}).me; network.nick = (this.irc || {}).me;
network.join = _.pluck( network.join = _.map(
_.where(this.channels, {type: "channel"}), _.filter(this.channels, {type: "channel"}),
"name" "name"
).join(","); ).join(",");
return network; return network;

View file

@ -10,7 +10,7 @@ module.exports = function(network, chan, cmd, args) {
var irc = network.irc; var irc = network.irc;
irc.notice(args[0], message); 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") { if (typeof targetChan === "undefined") {
message = "{to " + args[0] + "} " + message; message = "{to " + args[0] + "} " + message;
targetChan = chan; targetChan = chan;

View file

@ -5,7 +5,7 @@ module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("kick", function(data) { irc.on("kick", function(data) {
var from = data.nick; 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); var mode = chan.getMode(from);
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
@ -15,7 +15,7 @@ module.exports = function(irc, network) {
if (data.client === irc.me) { if (data.client === irc.me) {
chan.users = []; chan.users = [];
} else { } 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", { client.emit("users", {

View file

@ -29,7 +29,7 @@ module.exports = function(irc, network) {
} }
var self = data.to.toLowerCase() === irc.me.toLowerCase(); 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") { if (typeof chan === "undefined") {
return; return;
} }

View file

@ -15,7 +15,7 @@ module.exports = function(irc, network) {
target = data.from; target = data.from;
} }
var chan = _.findWhere(network.channels, {name: target}); var chan = _.find(network.channels, {name: target});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,

View file

@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("mode", function(data) { 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") { if (typeof chan !== "undefined") {
setTimeout(function() { setTimeout(function() {
irc.write("NAMES " + data.target); irc.write("NAMES " + data.target);

View file

@ -4,7 +4,7 @@ var User = require("../../models/user");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("names", function(data) { 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") { if (typeof chan === "undefined") {
return; return;
} }

View file

@ -24,7 +24,7 @@ module.exports = function(irc, network) {
}); });
} }
network.channels.forEach(function(chan) { 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") { if (typeof user === "undefined") {
return; return;
} }

View file

@ -9,7 +9,7 @@ module.exports = function(irc, network) {
target = data.from; target = data.from;
} }
var chan = _.findWhere(network.channels, {name: target}); var chan = _.find(network.channels, {name: target});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = network.channels[0]; chan = network.channels[0];
} }

View file

@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("part", function(data) { 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") { if (typeof chan === "undefined") {
return; return;
} }
@ -16,7 +16,7 @@ module.exports = function(irc, network) {
chan: chan.id chan: chan.id
}); });
} else { } else {
var user = _.findWhere(chan.users, {name: from}); var user = _.find(chan.users, {name: from});
chan.users = _.without(chan.users, user); chan.users = _.without(chan.users, user);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id

View file

@ -6,7 +6,7 @@ module.exports = function(irc, network) {
irc.on("quit", function(data) { irc.on("quit", function(data) {
network.channels.forEach(function(chan) { network.channels.forEach(function(chan) {
var from = data.nick; var from = data.nick;
var user = _.findWhere(chan.users, {name: from}); var user = _.find(chan.users, {name: from});
if (typeof user === "undefined") { if (typeof user === "undefined") {
return; return;
} }

View file

@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("topic", function(data) { 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") { if (typeof chan === "undefined") {
return; return;
} }

View file

@ -8,7 +8,7 @@ module.exports = function(irc, network) {
if (data === null) { if (data === null) {
return; return;
} }
var chan = _.findWhere(network.channels, {name: data.nickname}); var chan = _.find(network.channels, {name: data.nickname});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,

View file

@ -77,12 +77,10 @@ function index(req, res, next) {
require("../package.json"), require("../package.json"),
config config
); );
var template = _.template(file);
res.setHeader("Content-Type", "text/html"); res.setHeader("Content-Type", "text/html");
res.writeHead(200); res.writeHead(200);
res.end(_.template( res.end(template(data));
file,
data
));
}); });
} }