92green / enty

Normalized State Management
MIT License
6 stars 1 forks source link

fix for very strange issue where reduce iteration iterated too many times #139

Closed dancoates closed 4 years ago

dancoates commented 4 years ago

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.