Index: lib/src/utils.dart |
diff --git a/lib/src/utils.dart b/lib/src/utils.dart |
index 4b554ee53ecb93b01f83a3f231b7d42b29b43168..74675907fe92db84d07a21e0ee368e8f0c9616f3 100644 |
--- a/lib/src/utils.dart |
+++ b/lib/src/utils.dart |
@@ -34,6 +34,9 @@ final lineSplitter = UTF8.decoder.fuse(const LineSplitter()); |
/// [Object.toString] values contain. |
final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); |
+/// A regular expression matching a single vowel. |
+final _vowel = new RegExp('[aeiou]'); |
+ |
/// Directories that are specific to OS X. |
/// |
/// This is used to try to distinguish OS X and Linux in [currentOSGuess]. |
@@ -118,6 +121,10 @@ String pluralize(String name, int number, {String plural}) { |
return '${name}s'; |
} |
+/// Returns [noun] with an indefinite article ("a" or "an") added, based on |
+/// whether its first letter is a vowel. |
+String a(String noun) => noun.startsWith(_vowel) ? "an $noun" : "a $noun"; |
+ |
/// Wraps [text] so that it fits within [lineLength], which defaults to 100 |
/// characters. |
/// |