Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from emonkak/2.0
Version 2.0
- Loading branch information
Showing
7 changed files
with
13 additions
and
18 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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import maxByFn from '../maxBy'; | ||
import { Enumerable } from '../internal/Enumerable'; | ||
|
||
function maxBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): TSource[] { | ||
return maxByFn.call(this.source, keySelector); | ||
function maxBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource> { | ||
return this.lift<TSource>(maxByFn.call(this.source, keySelector)); | ||
} | ||
|
||
Enumerable.prototype.maxBy = maxBy; | ||
|
||
declare module '../internal/Enumerable' { | ||
interface Enumerable<TSource> { | ||
maxBy<TKey>(keySelector: (element: TSource) => TKey): TSource[]; | ||
maxBy<TKey>(keySelector: (element: TSource) => TKey): Enumerable<TSource>; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import minByFn from '../minBy'; | ||
import { Enumerable } from '../internal/Enumerable'; | ||
|
||
function minBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): TSource[] { | ||
return minByFn.call(this.source, keySelector); | ||
function minBy<TSource, TKey>(this: Enumerable<TSource>, keySelector: (element: TSource) => TKey): Enumerable<TSource> { | ||
return this.lift<TSource>(minByFn.call(this.source, keySelector)); | ||
} | ||
|
||
Enumerable.prototype.minBy = minBy; | ||
|
||
declare module '../internal/Enumerable' { | ||
interface Enumerable<TSource> { | ||
minBy<TKey>(keySelector: (element: TSource) => TKey): TSource[]; | ||
minBy<TKey>(keySelector: (element: TSource) => TKey): Enumerable<TSource>; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function toArray<TSource>(this: Iterable<TSource>): TSource[] { | ||
return Array.from(this); | ||
return Array.isArray(this) ? this as TSource[] : Array.from(this); | ||
} |
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