Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: packages/which/lib/src/util.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/which/lib/src/is_executable.dart ('k') | packages/which/lib/src/which_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 library which.src.util; 2 library which.src.util;
3 3
4 import 'dart:async'; 4 import 'dart:async';
5 5
6 /// Transparently call `firstWhere` on a [Stream] or [Iterable]. 6 /// Transparently call `firstWhere` on a [Stream] or [Iterable].
7 // TODO: Remove once https://dartbug.com/ is fixed. 7 // TODO: Remove once https://dartbug.com/ is fixed.
8 firstWhere(sequence, test, { orElse() }) => sequence is Iterable ? 8 firstWhere(sequence, test, { orElse() }) => sequence is Iterable ?
9 sequence.firstWhere(test, orElse: orElse) : 9 sequence.firstWhere(test, orElse: orElse) :
10 _streamFirstWhere(sequence, test, orElse: orElse); 10 _streamFirstWhere(sequence, test, orElse: orElse);
11 11
12 Future _streamFirstWhere(Stream stream, test(item), { orElse() }) { 12 Future _streamFirstWhere(Stream stream, test(item), { orElse() }) {
13 var pairs = stream.asyncMap((item) => test(item).then((result) => [item, resul t])); 13 var pairs = stream.asyncMap((item) => test(item).then((result) => [item, resul t]));
14 return pairs.firstWhere((pair) => pair.last, defaultValue: () => [orElse(), nu ll]).then((pair) => pair.first); 14 return pairs.firstWhere((pair) => pair.last, defaultValue: () => [orElse(), nu ll]).then((pair) => pair.first);
15 } 15 }
16 16
17 /// The identity function simply returns its argument ([x]). 17 /// The identity function simply returns its argument ([x]).
18 identity(x) => x; 18 identity(x) => x;
OLDNEW
« no previous file with comments | « packages/which/lib/src/is_executable.dart ('k') | packages/which/lib/src/which_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698