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

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 566093003: Create binstubs for executables when activating a package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 7af41e5f7ec03bef60391c16a6976a58a347ddf8..6e44ecb656f861990579ddba312c53e2e632bcf2 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -167,6 +167,19 @@ String padRight(String source, int length) {
return result.toString();
}
+/// Returns a labelled sentence fragment starting with [name] listing the
+/// elements [iter].
+///
+/// If [iter] does not have one item, name will be pluralized by adding "s" or
+/// using [plural], if given.
+String namedSequence(String name, Iterable iter, [String plural]) {
+ if (iter.length == 1) return "$name ${iter.first}";
nweiz 2014/09/15 22:57:18 Nit: I like [iter.single] here.
Bob Nystrom 2014/09/17 21:34:35 Done.
+
+ var sequence = iter.take(iter.length - 1).join(", ") + " and ${iter.last}";
nweiz 2014/09/15 22:57:18 Use [toSentence] here.
Bob Nystrom 2014/09/17 21:34:35 Done.
+ if (plural == null) plural = "${name}s";
+ return "$plural $sequence";
+}
+
/// Returns a sentence fragment listing the elements of [iter].
///
/// This converts each element of [iter] to a string and separates them with

Powered by Google App Engine
This is Rietveld 408576698