Skip to content

v2.0.0

Latest
Compare
Choose a tag to compare
@adamhamlin adamhamlin released this 10 Apr 02:33

Adding 2 breaking changes:

  • Changed/improved the semantics for DeepMap.difference() and DeepMap.intersection() such that they will only consider an entry to "match" if both the key and its value are equivalent--instead of just the key.

    const map1 = new DeepMap([[1, "dog"], [2, "cat"]]);
    const map2 = new DeepMap([[1, "dog"], [2, "laser-cat"]]);
    
    const pairsInMap1NotInMap2 = map1.difference(map2);
    const pairsInBothMaps = map1.intersection(map2);
                
    expect([...pairsInMap1NotInMap2.entries()]).toStrictEqual([[2, "cat"]]); // previously would have been: [[]]
    expect([...pairsInBothMaps.entries()]).toStrictEqual([[1, "dog"]]); // previously would have been: [[1, "dog"], [2, "cat"]]
  • Library will now enforce that two structures are using the same options during comparison operations like .equals, .union, etc. This is to prevent a potential footgun/unexpected behavior.

    const set1 = new DeepSet(["DOG", "CAT"]);
    const set2 = new DeepSet(["dog", "cat"], { caseInsensitive: true });
    
    set1.equals(set2); // errors; previously, no error