git ssb

0+

Piet / ssb-loomio



Commit 6722d5e0408124332904314dfb6c84ed5e98b49c

Use some destructuring and const

Piet Geursen committed on 3/7/2018, 1:04:57 AM
Parent: 97bde7ce4cb8f440a82828ea953f2e6f63c7e20e

Files changed

position/sync/chooseOneResults.jschanged
position/sync/chooseOneResults.jsView
@@ -1,6 +1,6 @@
1-var isArray = require('isarray')
2-var Position = require('../../position/sync/position')
1+const isArray = require('isarray')
2+const Position = require('../../position/sync/position')
33
44 // Expects `poll` and `position` objects passed in to be of shape:
55 // {
66 // value: {
@@ -12,9 +12,10 @@
1212 //
1313 // postions must be of the correct type ie: type checked by the caller.
1414 module.exports = function ({positions, poll}) {
1515 return positions.reduce(function (results, position) {
16- var { positionDetails: {choice} } = Position(position)
16+ const { value: {author}} = position
17+ const { positionDetails: {choice} } = Position(position)
1718
1819 if (isInvalidChoice({position, poll}) || isPositionAfterClose({position, poll})) {
1920 results.errors.invalidPositions.push(position)
2021 return results
@@ -22,16 +23,16 @@
2223
2324 if (!isArray(results[choice])) {
2425 results[choice] = []
2526 }
26- results[choice].push(position.value.author)
27+ results[choice].push(author)
2728
2829 return results
2930 }, {errors: {invalidPositions: []}})
3031 }
3132
3233 function isInvalidChoice ({position, poll}) {
33- var { positionDetails: {choice} } = Position(position)
34+ const { positionDetails: {choice} } = Position(position)
3435 return choice >= poll.pollDetails.choices.length
3536 }
3637
3738 function isPositionAfterClose ({position, poll}) {

Built with git-ssb-web