From f5417335f092dcf4d7559d895e7ce13e8a55fd7b Mon Sep 17 00:00:00 2001 From: Ryan Feline Date: Wed, 23 Aug 2017 07:51:21 +0100 Subject: [PATCH] Extract explanatory functions from mover. --- TelepresenceBot/server-unit/core/mover.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/TelepresenceBot/server-unit/core/mover.js b/TelepresenceBot/server-unit/core/mover.js index 4612c2fca..1b340a5ed 100644 --- a/TelepresenceBot/server-unit/core/mover.js +++ b/TelepresenceBot/server-unit/core/mover.js @@ -1,12 +1,17 @@ module.exports = function Mover(clientsAndRooms, emitter) { + + var emitToRoom = function (direction) { + return function (room) { + emitter.to(room).emit('direction', direction); + } + } + return { moveIn: function (clientId, direction) { var rooms = clientsAndRooms[clientId]; Object.keys(rooms || {}) - .map(function (room) { - emitter.to(room).emit('direction', direction); - }); + .every(emitToRoom(direction)); } }; }