Skip to content

Commit

Permalink
feat(IObjectComparer): New common object comparer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-b committed Sep 27, 2017
1 parent a4fe683 commit e72d765
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/objectComparer.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IObjectComparer {
areEquivalent (objA: any, objB: any): boolean
}
10 changes: 10 additions & 0 deletions src/common/stringifyComparer.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IObjectComparer } from './objectComparer.interface'

/**
* Compares objects using `JSON.stringify`
*/
export class StringifyComparer implements IObjectComparer {
public areEquivalent (objA: any, objB: any): boolean {
return JSON.stringify(objA) === JSON.stringify(objB)
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export { Suit } from './models/card/suit.model'
export { ChipColor } from './models/chip/chipColor.model'
export { ChipColorType } from './models/chip/chipColorType.model'
export { Difficulty } from './models/player/difficulty.model'
export { IObjectComparer } from './common/objectComparer.interface'
export { StringifyComparer } from './common/stringifyComparer.model'

export { ICard } from './models/card/card.interface'
export { IRankSet } from './models/card/rankSet.interface'
Expand Down

0 comments on commit e72d765

Please sign in to comment.