Very hard to replicate but in the edgiest of edge cases the reduce loop
would iterate over the first item twice. For example if Object.keys(shape)
were ['item1', 'item2'] then it would iterate with values of:
'item1'
'item1'
'item2'
That shouldn't be possible but it was definitely happening. This change
uses a for loop rather than .reduce. The reduce wasn't super necessary
as it was mutating the object anyway. This should also have a slight
performance increase.
Very hard to replicate but in the edgiest of edge cases the reduce loop would iterate over the first item twice. For example if Object.keys(shape) were ['item1', 'item2'] then it would iterate with values of:
'item1' 'item1' 'item2'
That shouldn't be possible but it was definitely happening. This change uses a for loop rather than .reduce. The reduce wasn't super necessary as it was mutating the object anyway. This should also have a slight performance increase.