Closed ssmyczynski closed 5 years ago
The size property of SortedMap gets unsynchronised from its actual size what also breaks functions depending on it e.g. takeLast.
Just try this snippet of code:
import { SortedMap } from 'immutable-sorted'; let operations = [[26,true],[112,false],[141,true],[185,true],[2,true],[4,false],[51,true],[1,false],[144,false],[40,false],[150,true],[30,true],[109,true],[113,true],[78,false],[173,true],[142,false],[47,false],[92,true],[64,true],[68,true],[135,true],[147,true],[85,true],[135,false],[44,false],[82,true],[136,false],[61,true],[22,false],[70,false],[62,true],[186,true],[10,true],[193,true],[89,false],[71,true],[98,true],[123,true],[166,true],[85,true],[54,true],[89,true],[192,false],[194,true],[174,false],[134,true],[47,true],[137,true],[34,true],[192,true],[92,false],[16,false],[92,true]]; var map = new SortedMap(); for([key, set] of operations) { map = set ? map.set(key, key) : map.delete(key); } console.log(map.size, map.toList().size);
expected output should be 33 33 but is 32 33
Thank you for catching and fixing this bug! Your pull request has been merged and new version of immutable-sorted@0.2.7 has been published to npm.
What happened
The size property of SortedMap gets unsynchronised from its actual size what also breaks functions depending on it e.g. takeLast.
How to reproduce
Just try this snippet of code:
expected output should be 33 33 but is 32 33