本文整理匯總了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))