Index: sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
index 395f970950757c552d77e0d0ae35d88f1c005f08..e6184c0d893fc9fe19a4db0f3bc1b97c00464754 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
@@ -137,7 +137,7 @@ class JSString extends Interceptor implements String, JSIndexable { |
return JS('String', r'#.trim()', this); |
} |
- List<int> get codeUnits => new CodeUnits(this); |
+ List<int> get codeUnits => new _CodeUnits(this); |
Runes get runes => new Runes(this); |
@@ -211,3 +211,16 @@ class JSString extends Interceptor implements String, JSIndexable { |
return JS('String', '#[#]', this, index); |
} |
} |
+ |
+/** |
+ * An [Iterable] of the UTF-16 code units of a [String] in index order. |
+ */ |
+class _CodeUnits extends UnmodifiableListBase<int> { |
+ /** The string that this is the code units of. */ |
+ String _string; |
+ |
+ _CodeUnits(this._string); |
+ |
+ int get length => _string.length; |
+ int operator[](int i) => _string.codeUnitAt(i); |
+} |