Skip to content

Commit

Permalink
fix: Address a breakage in the last refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Mar 11, 2016
1 parent 7e53f75 commit 5a214fd
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/utils/Omnom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export class Omnom {
return new Omnom(options).diff(original, modified).changes;
}

private onObject(original: number, modified: number, changePath?: string);
private onObject(original: [any], modified: any[], changePath?: string);
private onObject(original: MongoDB.ObjectID, modified: MongoDB.ObjectID, changePath?: string);
private onObject(original: Object, modified: Object, changePath?: string);
private onObject(original: any, modified: any, changePath?: string) {
private onObject(original: number, modified: number, changePath?: string): void;
private onObject(original: [any], modified: any[], changePath?: string): void;
private onObject(original: MongoDB.ObjectID, modified: MongoDB.ObjectID, changePath?: string): void;
private onObject(original: Object, modified: Object, changePath?: string): void;
private onObject(original: any, modified: any, changePath?: string): void {
if (original === undefined || original === null)
return (original !== modified) && this.set(changePath, modified);

Expand Down Expand Up @@ -90,7 +90,7 @@ export class Omnom {
}, this);
}

private onArray(original: any[], modified: any[], changePath: string) {
private onArray(original: any[], modified: any[], changePath: string): void {
// Check if we can get from original => modified using just pulls
if (original.length > modified.length) {
return this.onSmallerArray(original, modified, changePath);
Expand All @@ -105,7 +105,7 @@ export class Omnom {
return this.onSimilarArray(original, modified, changePath);
}

private onSmallerArray(original: any[], modified: any[], changePath: string) {
private onSmallerArray(original: any[], modified: any[], changePath: string): void {
let pulls = [];
let i = 0;
let j = 0;
Expand All @@ -129,7 +129,7 @@ export class Omnom {
else return this.set(changePath, modified);
}

private onLargerArray(original: any[], modified: any[], changePath: string) {
private onLargerArray(original: any[], modified: any[], changePath: string): void {
let canPush = true;
for (let i = 0; i < original.length; i++)
if (this.almostEqual(original[i], modified[i]) < 1) {
Expand All @@ -142,9 +142,11 @@ export class Omnom {
this.push(changePath, modified[i]);
return;
}

return this.onSimilarArray(original, modified, changePath);
}

private onSimilarArray(original: any[], modified: any[], changePath: string) {
private onSimilarArray(original: any[], modified: any[], changePath: string): void {
// Check how many manipulations would need to be performed, if it's more than half the array size
// then rather re-create the array
let sets = [];
Expand Down

0 comments on commit 5a214fd

Please sign in to comment.