| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The type used by the | 8 * The type used by the |
| 9 * [Window.localStorage] and [Window.sessionStorage] properties. | 9 * [Window.localStorage] and [Window.sessionStorage] properties. |
| 10 * Storage is implemented as a Map<String, String>. | 10 * Storage is implemented as a Map<String, String>. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * For details on using the Map API, see the | 28 * For details on using the Map API, see the |
| 29 * [Maps](http://www.dartlang.org/docs/library-tour/#maps-aka-dictionaries-or-ha
shes) | 29 * [Maps](http://www.dartlang.org/docs/library-tour/#maps-aka-dictionaries-or-ha
shes) |
| 30 * section of the library tour. | 30 * section of the library tour. |
| 31 */ | 31 */ |
| 32 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS | 32 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS |
| 33 implements Map<String, String> $NATIVESPEC { | 33 implements Map<String, String> $NATIVESPEC { |
| 34 | 34 |
| 35 // TODO(nweiz): update this when maps support lazy iteration | 35 // TODO(nweiz): update this when maps support lazy iteration |
| 36 bool containsValue(String value) => values.any((e) => e == value); | 36 bool containsValue(String value) => values.any((e) => e == value); |
| 37 | 37 |
| 38 bool containsKey(String key) => $dom_getItem(key) != null; | 38 bool containsKey(String key) => _getItem(key) != null; |
| 39 | 39 |
| 40 String operator [](String key) => $dom_getItem(key); | 40 String operator [](String key) => _getItem(key); |
| 41 | 41 |
| 42 void operator []=(String key, String value) { $dom_setItem(key, value); } | 42 void operator []=(String key, String value) { _setItem(key, value); } |
| 43 | 43 |
| 44 String putIfAbsent(String key, String ifAbsent()) { | 44 String putIfAbsent(String key, String ifAbsent()) { |
| 45 if (!containsKey(key)) this[key] = ifAbsent(); | 45 if (!containsKey(key)) this[key] = ifAbsent(); |
| 46 return this[key]; | 46 return this[key]; |
| 47 } | 47 } |
| 48 | 48 |
| 49 String remove(String key) { | 49 String remove(String key) { |
| 50 final value = this[key]; | 50 final value = this[key]; |
| 51 $dom_removeItem(key); | 51 _removeItem(key); |
| 52 return value; | 52 return value; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void clear() => $dom_clear(); | 55 void clear() => _clear(); |
| 56 | 56 |
| 57 void forEach(void f(String key, String value)) { | 57 void forEach(void f(String key, String value)) { |
| 58 for (var i = 0; true; i++) { | 58 for (var i = 0; true; i++) { |
| 59 final key = $dom_key(i); | 59 final key = _key(i); |
| 60 if (key == null) return; | 60 if (key == null) return; |
| 61 | 61 |
| 62 f(key, this[key]); | 62 f(key, this[key]); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 Iterable<String> get keys { | 66 Iterable<String> get keys { |
| 67 final keys = []; | 67 final keys = []; |
| 68 forEach((k, v) => keys.add(k)); | 68 forEach((k, v) => keys.add(k)); |
| 69 return keys; | 69 return keys; |
| 70 } | 70 } |
| 71 | 71 |
| 72 Iterable<String> get values { | 72 Iterable<String> get values { |
| 73 final values = []; | 73 final values = []; |
| 74 forEach((k, v) => values.add(v)); | 74 forEach((k, v) => values.add(v)); |
| 75 return values; | 75 return values; |
| 76 } | 76 } |
| 77 | 77 |
| 78 int get length => $dom_length; | 78 int get length => _length; |
| 79 | 79 |
| 80 bool get isEmpty => $dom_key(0) == null; | 80 bool get isEmpty => _key(0) == null; |
| 81 | 81 |
| 82 bool get isNotEmpty => !isEmpty; | 82 bool get isNotEmpty => !isEmpty; |
| 83 $!MEMBERS | 83 $!MEMBERS |
| 84 } | 84 } |
| OLD | NEW |