Skip to content

Commit 3f770b8

Browse files
committed
Rename diff -> diffAgainst
1 parent 360dc5e commit 3f770b8

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

b+tree.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,13 @@ export default class BTree<K = any, V = any> implements ISortedMapF<K, V>, ISort
261261
* of shared data (obtained by calling the `clone` or `with` APIs) and will avoid
262262
* any iteration of shared state.
263263
* The handlers can cause computation to early exit by returning {break: R}.
264+
* Neither of the collections should be changed during the comparison process (in your callbacks), as this method assumes they will not be mutated.
264265
* @param other The tree to compute a diff against.
265266
* @param onlyThis Callback invoked for all keys only present in `this`.
266267
* @param onlyOther Callback invoked for all keys only present in `other`.
267268
* @param different Callback invoked for all keys with differing values.
268269
*/
269-
diff<R>(other: BTree<K, V>, onlyThis?: (k: K, v: V) => {
270+
diffAgainst<R>(other: BTree<K, V>, onlyThis?: (k: K, v: V) => {
270271
break?: R;
271272
} | void, onlyOther?: (k: K, v: V) => {
272273
break?: R;

b+tree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,13 @@ var BTree = /** @class */ (function () {
495495
* of shared data (obtained by calling the `clone` or `with` APIs) and will avoid
496496
* any iteration of shared state.
497497
* The handlers can cause computation to early exit by returning {break: R}.
498+
* Neither of the collections should be changed during the comparison process (in your callbacks), as this method assumes they will not be mutated.
498499
* @param other The tree to compute a diff against.
499500
* @param onlyThis Callback invoked for all keys only present in `this`.
500501
* @param onlyOther Callback invoked for all keys only present in `other`.
501502
* @param different Callback invoked for all keys with differing values.
502503
*/
503-
BTree.prototype.diff = function (other, onlyThis, onlyOther, different) {
504+
BTree.prototype.diffAgainst = function (other, onlyThis, onlyOther, different) {
504505
if (other._compare !== this._compare) {
505506
throw new Error("Tree comparators are not the same.");
506507
}

b+tree.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ function testBTree(maxNodeSize: number)
605605

606606
function expectDiffCorrect(treeThis: BTree<number, number>, treeOther: BTree<number, number>): void {
607607
reset();
608-
treeThis.diff(treeOther, OnlyThis, OnlyOther, Different);
608+
treeThis.diffAgainst(treeOther, OnlyThis, OnlyOther, Different);
609609
let onlyThisT: Map<number, number> = new Map();
610610
let onlyOtherT: Map<number, number> = new Map();
611611
let differentT: Map<number, string> = new Map();
@@ -631,7 +631,7 @@ function testBTree(maxNodeSize: number)
631631
test(`Diff of trees with different comparators is an error`, () => {
632632
const treeA = new BTree<number, number>([], compare);
633633
const treeB = new BTree<number, number>([], (a, b) => b - a);
634-
expect(() => treeA.diff(treeB, OnlyThis, OnlyOther, Different)).toThrow('comparators');
634+
expect(() => treeA.diffAgainst(treeB, OnlyThis, OnlyOther, Different)).toThrow('comparators');
635635
});
636636

637637
const entriesGroup: [number, number][][] = [[], [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]];
@@ -691,7 +691,7 @@ function testBTree(maxNodeSize: number)
691691
const modifiedInB1 = 3, modifiedInB2 = maxKey - 2;
692692
treeB.set(modifiedInB1, differingValue);
693693
treeB.set(modifiedInB2, differingValue)
694-
treeA.diff(treeB, OnlyThis, OnlyOther, Different);
694+
treeA.diffAgainst(treeB, OnlyThis, OnlyOther, Different);
695695
expectDiffCorrect(treeA, treeB);
696696
}
697697

@@ -723,19 +723,19 @@ function testBTree(maxNodeSize: number)
723723
tree2.set(110, -1);
724724
const ReturnKey = (key: number) => { return { break: key }; };
725725

726-
let val = tree.diff(tree2, OnlyThis, OnlyOther, ReturnKey);
726+
let val = tree.diffAgainst(tree2, OnlyThis, OnlyOther, ReturnKey);
727727
expect(onlyOther.size).toEqual(1);
728728
expect(onlyThis.size).toEqual(0);
729729
expect(val).toEqual(20);
730730
reset();
731731

732-
val = tree.diff(tree2, OnlyThis, ReturnKey, Different);
732+
val = tree.diffAgainst(tree2, OnlyThis, ReturnKey, Different);
733733
expect(different.size).toEqual(0);
734734
expect(onlyThis.size).toEqual(0);
735735
expect(val).toEqual(110);
736736
reset();
737737

738-
val = tree.diff(tree2, ReturnKey, OnlyOther, Different);
738+
val = tree.diffAgainst(tree2, ReturnKey, OnlyOther, Different);
739739
expect(different.size).toEqual(1);
740740
expect(onlyOther.size).toEqual(1);
741741
expect(val).toEqual(10);

b+tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ export default class BTree<K=any, V=any> implements ISortedMapF<K,V>, ISortedMap
579579
* @param onlyOther Callback invoked for all keys only present in `other`.
580580
* @param different Callback invoked for all keys with differing values.
581581
*/
582-
diff<R>(
582+
diffAgainst<R>(
583583
other: BTree<K, V>,
584584
onlyThis?: (k: K, v: V) => { break?: R } | void,
585585
onlyOther?: (k: K, v: V) => { break?: R } | void,

0 commit comments

Comments
 (0)