Skip to content

Commit 0fb0da5

Browse files
author
Connor Giles
committed
Added some comments
1 parent 0202126 commit 0fb0da5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ app.use(express.static('public'))
2525

2626
app.post('/strokes', function (req, res) {
2727
if (req.body.length > 0 && req.body[0].user) console.log (`Recieved ${req.body.length} strokes from ${req.body[0].user}`);
28+
// Insert distinct values
29+
// This joins the values as a string, makes a set from them, casts to an array and then splits back to distanct data points
2830
let insertValues = Array.from(new Set(req.body.map(r => {
2931
try {
3032
return [r.user, Number(r.time), Number(r.keyCode), Number(r.modifiers), r.direction]
3133
} catch(e) {
32-
3334
}
3435
}).filter((i) => i).map(r => r.join(',')))).map(r => r.split(','))
3536

0 commit comments

Comments
 (0)