(sortProperties)
| 68 | |
| 69 | // sortProperties is an array whose items are each [propertyName, direction]. |
| 70 | function snapshotComparator(sortProperties) { |
| 71 | return function(snapshotA, snapshotB) { |
| 72 | for (var i = 0; i < sortProperties.length; i++) { |
| 73 | var sortProperty = sortProperties[i]; |
| 74 | var sortKey = sortProperty[0]; |
| 75 | var sortDirection = sortProperty[1]; |
| 76 | |
| 77 | var aPropVal = snapshotA.data[sortKey]; |
| 78 | var bPropVal = snapshotB.data[sortKey]; |
| 79 | if (aPropVal < bPropVal) { |
| 80 | return -1 * sortDirection; |
| 81 | } else if (aPropVal > bPropVal) { |
| 82 | return sortDirection; |
| 83 | } else if (aPropVal === bPropVal) { |
| 84 | continue; |
| 85 | } else { |
| 86 | throw new Error('Could not compare ' + aPropVal + ' and ' + bPropVal); |
| 87 | } |
| 88 | } |
| 89 | return 0; |
| 90 | }; |
| 91 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…