(flexItems: FlexItem[])
| 272 | } |
| 273 | |
| 274 | function cascadeRounding(flexItems: FlexItem[]): number[] { |
| 275 | /* |
| 276 | Given an array of floats that sum to an integer, this rounds the floats |
| 277 | and returns an array of integers with the same sum. |
| 278 | */ |
| 279 | |
| 280 | let fpTotal = 0; |
| 281 | let intTotal = 0; |
| 282 | let roundedArray: number[] = []; |
| 283 | flexItems.forEach(function (item) { |
| 284 | let float = item.targetMainSize; |
| 285 | let integer = Math.round(float + fpTotal) - intTotal; |
| 286 | fpTotal += float; |
| 287 | intTotal += integer; |
| 288 | roundedArray.push(integer); |
| 289 | }); |
| 290 | |
| 291 | return roundedArray; |
| 292 | } |
no test coverage detected