Index: pkg/polymer_expressions/lib/src/globals.dart |
diff --git a/pkg/polymer_expressions/lib/src/globals.dart b/pkg/polymer_expressions/lib/src/globals.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0133a6ef9f0f7012429a78ae9af5fab52025cb97 |
--- /dev/null |
+++ b/pkg/polymer_expressions/lib/src/globals.dart |
@@ -0,0 +1,26 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+/** |
+ * Contains functions that are included by default in [PolymerExpressions]. |
+ * |
+ * - [enumerate]: a convenient way to iterate over items and the indexes. |
+ */ |
+library polymer_expressions.src.globals; |
+ |
+/** |
+ * Returns an [Iterable] of [IndexedValue]s where the nth value holds the nth |
+ * element of [iterable] and its index. |
+ */ |
+Iterable<IndexedValue> enumerate(Iterable iterable) { |
+ int i = 0; |
+ return iterable.map((e) => new IndexedValue(i++, e)); |
+} |
+ |
+class IndexedValue<V> { |
+ final int index; |
+ final V value; |
+ |
+ IndexedValue(this.index, this.value); |
+} |