j. If unit is "seconds", "milliseconds", or "microseconds", then
i. If unit is "seconds", then
1. Let nextStyle be durationFormat.[[MillisecondsStyle]].
ii. Else if unit is "milliseconds", then
1. Let nextStyle be durationFormat.[[MicrosecondsStyle]].
iii. Else,
1. Let nextStyle be durationFormat.[[NanosecondsStyle]].
iv. If nextStyle is "numeric", then
....
Could be replaced with:
j. If unit is "seconds", "milliseconds", or "microseconds", then
i. If style is "2-digit" or "numeric", then
....
This avoids reading the next style and the extra if-else steps.
Whoops, actually not correct → new Intl.DurationFormat("en", {seconds:"short", milliseconds:"numeric"}) has a numeric next style with a current style non-numeric.
PartitionDurationFormatPattern, steps 4.j.i-iv:
Could be replaced with:
This avoids reading the next style and the extra if-else steps.