本文整理汇总了TypeScript中linq.IEnumerable类的典型用法代码示例。如果您正苦于以下问题:TypeScript IEnumerable类的具体用法?TypeScript IEnumerable怎么用?TypeScript IEnumerable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IEnumerable类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should do type completion for joins', function () {
let other = Enumerable.from(['a', 'aaa']);
let actual: IEnumerable<string> = Enumerable
.range(1, 4)
.join(other, num => num, str => str.length, (num, len) => num + ':' + len);
expect(actual.toJoinedString(',')).to.equal('1:a,3:aaa');
});
示例2: bestAndWorstMovies
public static bestAndWorstMovies(movies: IEnumerable<Movie>): BestAndWorstMovies {
if (!movies.any((m) => m.rating != null)) {
return new BestAndWorstMovies([], []);
}
const bestMovieRating = movies.where((m) => m.rating !== null).max((m) => m.rating || 0);
const worstMovieRating = movies.where((m) => m.rating !== null).min((m) => m.rating || 0);
const bestMovies = movies.where((m) => m.rating === bestMovieRating).toArray();
const worstMovies = movies.where((m) => m.rating === worstMovieRating).toArray();
return new BestAndWorstMovies(bestMovies, worstMovies);
}
示例3: totalSharesByMovie
public static totalSharesByMovie(shares: IEnumerable<Share>, players: IEnumerable<Player>): number {
return shares
.where((s) => players.any((p) => p.id === s.playerId))
.select((v) => v.numShares)
.sum();
}
示例4: moviesForNewPage
public static moviesForNewPage(movies: IEnumerable<Movie>): MovieNewDisplay[] {
return movies.orderBy((movie) => movie.releaseDate).thenBy((movie) => movie.id).select(
(movie) => new MovieNewDisplay(movie)).toArray();
}
示例5: maxEarningByMovie
public static maxEarningByMovie(earnings: IEnumerable<Earning>): number {
const maxEarning = earnings.count() === 0 ? 0 :
earnings.orderByDescending((e) => e.createdAt).first().gross;
return maxEarning;
}
示例6:
.where((s) => players.any((p) => p.id === s.playerId))