-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #718 by moving the comparators into ApiComparators
Fixes #725 by eliminating one of the inits that was basically useless
- Loading branch information
1 parent
379d1f0
commit 0da02c1
Showing
9 changed files
with
77 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ApiSource, ApiPerson, ApiSubmitter } from '../models'; | ||
|
||
export class ApiComparators { | ||
comparePersons = function(a: ApiPerson, b: ApiPerson) { | ||
return this.twoPartCompare(a.indexName, a. string, b.indexName, b.string); | ||
}; | ||
|
||
compareSources = function(a: ApiSource, b: ApiSource) { | ||
return this.twoPartCompare(a.title, a. string, b.title, b.string); | ||
}; | ||
|
||
compareSubmitters = function(a: ApiSubmitter, b: ApiSubmitter) { | ||
return this.twoPartCompare(a.name, a.string, b.name, b.string); | ||
}; | ||
|
||
private twoPartCompare(a1: string, a2: string, b1: string, b2: string): number { | ||
const val = a1.localeCompare(b1); | ||
if (val !== 0) { | ||
return val; | ||
} | ||
return a2.localeCompare(b2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters