-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { IIterator } from "../intefaces/iterator.interface"; | ||
|
||
export class ContainsClause<T> implements IIterator<T> { | ||
|
||
_entity: T; | ||
|
||
execute(source: T[] | any[]): T[] | T | any { | ||
|
||
if (!source) return false; | ||
|
||
let _flag = false; | ||
for (let i = 0, li = source.length; i < li; i++) { | ||
if (source[i] === this._entity) { | ||
_flag = true; | ||
break; | ||
} | ||
} | ||
|
||
return _flag; | ||
} | ||
|
||
constructor(entity: T) { | ||
this._entity = entity; | ||
} | ||
} |
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,39 @@ | ||
import { IIterator } from "../intefaces/iterator.interface"; | ||
import { SelectClause } from "./select"; | ||
import { JoinClause } from "./join"; | ||
import { GroupByClause } from "./groupBy"; | ||
|
||
export class GroupJoinClause<T, S> implements IIterator<T> { | ||
|
||
_anotherSource: S[]; | ||
_joinIterator: (aEntity: T, bEntity: S) => boolean; | ||
_groupIterator: (entity: { x: T; y: S; }) => any; | ||
|
||
execute(source: T[]): T[] | any[] { | ||
|
||
if (!source) return null; | ||
|
||
let _result = new JoinClause(this._anotherSource, this._joinIterator).execute(source); | ||
|
||
_result = new GroupByClause(this._groupIterator).execute(_result as { x: T; y: S; }[]); | ||
|
||
return _result; | ||
|
||
} | ||
|
||
constructor( | ||
anotherSource: S[], | ||
joinIterator: (aEntity: T, bEntity: S) => boolean, | ||
groupIterator: (entity: { x: T; y: S; }) => any) { | ||
|
||
this._joinIterator = joinIterator; | ||
this._groupIterator = groupIterator; | ||
this._anotherSource = anotherSource; | ||
} | ||
|
||
private distinct(array: any[]) { | ||
return array.filter((val, index, self) => { | ||
return self.indexOf(val) === index; | ||
}).filter(x => x != undefined); | ||
} | ||
} |
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