Update lodash

This commit is contained in:
Pavel Djundik 2016-02-14 19:09:51 +02:00
parent 4413a56e12
commit 19bc4f37e0
16 changed files with 20 additions and 23 deletions

View File

@ -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",

View File

@ -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);
};

View File

@ -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;

View File

@ -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;

View File

@ -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", {

View File

@ -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;
}

View File

@ -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,

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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];
}

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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,

View File

@ -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));
});
}