git ssb

0+

Piet / ssb-loomio



Commit b1e8e452150195a02b9351e065a55fbc1f552c23

Adds first pass at reducer function.

Piet Geursen committed on 3/6/2018, 2:06:34 AM
Parent: 17445d27af23c12c79234b9d06909eb97e55ad50

Files changed

position/sync/chooseOneResults.jsadded
position/sync/chooseOneResults.jsView
@@ -1,0 +1,14 @@
1+var isPosition = require('./isPosition')
2+
3+module.exports = function (positions) {
4+ positions.reduce(function (results, position) {
5+ if (!isPosition(position)) {
6+ return results
7+ }
8+ var { choice } = position
9+ var currentScore = results[choice]
10+ results[choice] = currentScore ? currentScore + 1 : 1
11+
12+ return results
13+ }, {})
14+}

Built with git-ssb-web