Skip to content

Commit d0c870f

Browse files
committed
feat(facade/collection): add StringMap support
1 parent d4c099d commit d0c870f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

modules/facade/src/collection.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ class MapWrapper {
1414
static int size(m) {return m.length;}
1515
}
1616

17+
// TODO: how to export StringMap=Map as a type?
18+
class StringMapWrapper {
19+
static HashMap create() => new HashMap();
20+
static get(map, key) {
21+
return map[key];
22+
}
23+
static set(map, key, value) {
24+
map[key] = value;
25+
}
26+
}
27+
1728
class ListWrapper {
1829
static List clone(List l) => new List.from(l);
1930
static List create() => new List();

modules/facade/src/collection.es6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ export class MapWrapper {
1313
static size(m) {return m.size;}
1414
}
1515

16+
// TODO: cannot export StringMap as a type as Dart does not support
17+
// renaming types...
18+
export class StringMapWrapper {
19+
// Note: We are not using Object.create(null) here due to
20+
// performance!
21+
static create():Object { return { }; }
22+
static get(map, key) {
23+
return map.hasOwnProperty(key) ? map[key] : undefined;
24+
}
25+
static set(map, key, value) {
26+
map[key] = value;
27+
}
28+
}
1629

1730
export class ListWrapper {
1831
static create():List { return new List(); }

0 commit comments

Comments
 (0)