(flexItems: FlexItem[])
| 258 | } |
| 259 | |
| 260 | function cascadeRounding(flexItems: FlexItem[]): number[] { |
| 261 | /* |
| 262 | Given an array of floats that sum to an integer, this rounds the floats |
| 263 | and returns an array of integers with the same sum. |
| 264 | */ |
| 265 | |
| 266 | let fpTotal = 0; |
| 267 | let intTotal = 0; |
| 268 | let roundedArray: number[] = []; |
| 269 | flexItems.forEach(function (item) { |
| 270 | let float = item.targetMainSize; |
| 271 | let integer = Math.round(float + fpTotal) - intTotal; |
| 272 | fpTotal += float; |
| 273 | intTotal += integer; |
| 274 | roundedArray.push(integer); |
| 275 | }); |
| 276 | |
| 277 | return roundedArray; |
| 278 | } |
no test coverage detected