OLD | NEW |
1 dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ | 1 dart_library.library('collection/src/canonicalized_map', null, /* Imports */[ |
2 "dart/_runtime", | 2 "dart/_runtime", |
3 'dart/core', | 3 'dart/core', |
4 'collection/src/utils', | 4 'collection/src/utils', |
5 'dart/collection' | 5 'dart/collection' |
6 ], /* Lazy imports */[ | 6 ], /* Lazy imports */[ |
7 ], function(exports, dart, core, utils, collection) { | 7 ], function(exports, dart, core, utils, collection) { |
8 'use strict'; | 8 'use strict'; |
9 let dartx = dart.dartx; | 9 let dartx = dart.dartx; |
10 const _base = Symbol('_base'); | 10 const _base = Symbol('_base'); |
11 const _canonicalize = Symbol('_canonicalize'); | 11 const _canonicalize = Symbol('_canonicalize'); |
12 const _isValidKeyFn = Symbol('_isValidKeyFn'); | 12 const _isValidKeyFn = Symbol('_isValidKeyFn'); |
13 const _isValidKey = Symbol('_isValidKey'); | 13 const _isValidKey = Symbol('_isValidKey'); |
14 const CanonicalizedMap$ = dart.generic(function(C, K, V) { | 14 const CanonicalizedMap$ = dart.generic(function(C, K, V) { |
15 class CanonicalizedMap extends core.Object { | 15 class CanonicalizedMap extends core.Object { |
16 CanonicalizedMap(canonicalize, {isValidKey = null} = {}) { | 16 CanonicalizedMap(canonicalize, opts) { |
| 17 let isValidKey = opts && 'isValidKey' in opts ? opts.isValidKey : null; |
17 this[_base] = core.Map$(C, utils.Pair$(K, V)).new(); | 18 this[_base] = core.Map$(C, utils.Pair$(K, V)).new(); |
18 this[_canonicalize] = canonicalize; | 19 this[_canonicalize] = canonicalize; |
19 this[_isValidKeyFn] = isValidKey; | 20 this[_isValidKeyFn] = isValidKey; |
20 } | 21 } |
21 from(other, canonicalize, {isValidKey = null} = {}) { | 22 from(other, canonicalize, opts) { |
| 23 let isValidKey = opts && 'isValidKey' in opts ? opts.isValidKey : null; |
22 this[_base] = core.Map$(C, utils.Pair$(K, V)).new(); | 24 this[_base] = core.Map$(C, utils.Pair$(K, V)).new(); |
23 this[_canonicalize] = canonicalize; | 25 this[_canonicalize] = canonicalize; |
24 this[_isValidKeyFn] = isValidKey; | 26 this[_isValidKeyFn] = isValidKey; |
25 this.addAll(other); | 27 this.addAll(other); |
26 } | 28 } |
27 get(key) { | 29 get(key) { |
28 if (!dart.notNull(this[_isValidKey](key))) | 30 if (!dart.notNull(this[_isValidKey](key))) |
29 return null; | 31 return null; |
30 let pair = this[_base].get(dart.dcall(this[_canonicalize], key)); | 32 let pair = this[_base].get(dart.dcall(this[_canonicalize], key)); |
31 return pair == null ? null : pair.last; | 33 return pair == null ? null : pair.last; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 [_isValidKey]: [core.bool, [core.Object]] | 110 [_isValidKey]: [core.bool, [core.Object]] |
109 }) | 111 }) |
110 }); | 112 }); |
111 return CanonicalizedMap; | 113 return CanonicalizedMap; |
112 }); | 114 }); |
113 let CanonicalizedMap = CanonicalizedMap$(); | 115 let CanonicalizedMap = CanonicalizedMap$(); |
114 // Exports: | 116 // Exports: |
115 exports.CanonicalizedMap$ = CanonicalizedMap$; | 117 exports.CanonicalizedMap$ = CanonicalizedMap$; |
116 exports.CanonicalizedMap = CanonicalizedMap; | 118 exports.CanonicalizedMap = CanonicalizedMap; |
117 }); | 119 }); |
OLD | NEW |