-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add ability to order sequences by types
fixes #249
- Loading branch information
1 parent
94f667b
commit 1ab78a3
Showing
13 changed files
with
490 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BreachProtocolRawData } from '@/core/common'; | ||
import { HierarchyProvider } from './hierarchy-provider'; | ||
import { IndexHierarchyProvider } from './index-hierarchy-provider'; | ||
|
||
export class TypesHierarchyProvider | ||
implements HierarchyProvider<BreachProtocolRawData> | ||
{ | ||
private readonly fallback = new IndexHierarchyProvider(); | ||
|
||
constructor(private readonly typesHierarchy: string[]) {} | ||
|
||
provide(data: BreachProtocolRawData): number[] { | ||
if (data.types) { | ||
return data.types.map((type) => | ||
this.typesHierarchy.findIndex((d) => d === type) | ||
); | ||
} | ||
|
||
return this.fallback.provide(data); | ||
} | ||
} |
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
Oops, something went wrong.