Commit 6cee7ba74d78d7a794627b917b1eef6f217416ff
Use destructuring
Piet Geursen committed on 3/6/2018, 2:06:34 AMParent: 2098413236ee6f4dd584c5a606b2036f11f2b177
Files changed
position/sync/chooseOneResults.js | changed |
position/sync/chooseOneResults.js | ||
---|---|---|
@@ -1,11 +1,13 @@ | ||
1 | 1 | var isArray = require('isarray') |
2 | 2 | var isPosition = require('../../isPosition') |
3 | 3 | var Position = require('../../position/sync/position') |
4 | 4 | |
5 | +//Expects a po | |
6 | + | |
5 | 7 | module.exports = function ({positions, poll}) { //postions must be of the correct type ie checked by the caller. |
6 | 8 | return positions.reduce(function (results, position) { |
7 | - var { choice } = Position(position).positionDetails | |
9 | + var { positionDetails: {choice} } = Position(position) | |
8 | 10 | |
9 | 11 | if (choice >= poll.pollDetails.choices.length || position.value.timestamp > poll.closesAt) { |
10 | 12 | results.errors.invalidPositions.push(position) |
11 | 13 | return results |
Built with git-ssb-web