MCPcopy
hub / github.com/socketio/socket.io / getUsernameColor

Function getUsernameColor

examples/cluster-nginx/server/public/main.js:180–189  ·  view source on GitHub ↗
(username)

Source from the content-addressed store, hash-verified

178
179 // Gets the color of a username through our hash function
180 function getUsernameColor (username) {
181 // Compute hash code
182 var hash = 7;
183 for (var i = 0; i < username.length; i++) {
184 hash = username.charCodeAt(i) + (hash << 5) - hash;
185 }
186 // Calculate color
187 var index = Math.abs(hash % COLORS.length);
188 return COLORS[index];
189 }
190
191 // Keyboard events
192

Callers 1

addChatMessageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected