OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart._runtime; | 4 part of dart._runtime; |
5 | 5 |
6 /// This library defines a set of general javascript utilities for us | 6 /// This library defines a set of general javascript utilities for us |
7 /// by the Dart runtime. | 7 /// by the Dart runtime. |
8 // TODO(ochafik): Rewrite some of these in Dart when possible. | 8 // TODO(ochafik): Rewrite some of these in Dart when possible. |
9 | 9 |
10 final defineProperty = JS('', 'Object.defineProperty'); | 10 final defineProperty = JS('', 'Object.defineProperty'); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return $to; | 95 return $to; |
96 })()'''); | 96 })()'''); |
97 | 97 |
98 /// Copy properties from source to destination object. | 98 /// Copy properties from source to destination object. |
99 /// This operation is commonly called `mixin` in JS. | 99 /// This operation is commonly called `mixin` in JS. |
100 copyProperties(to, from) => JS('', '''(() => { | 100 copyProperties(to, from) => JS('', '''(() => { |
101 return $copyTheseProperties($to, $from, $getOwnNamesAndSymbols($from)); | 101 return $copyTheseProperties($to, $from, $getOwnNamesAndSymbols($from)); |
102 })()'''); | 102 })()'''); |
103 | 103 |
104 /// Exports from one Dart module to another. | 104 /// Exports from one Dart module to another. |
105 @JSExportName('export') | |
106 export_(to, from, show, hide) => JS('', '''(() => { | 105 export_(to, from, show, hide) => JS('', '''(() => { |
107 if ($show == void 0 || $show.length == 0) { | 106 if ($show == void 0 || $show.length == 0) { |
108 $show = $getOwnNamesAndSymbols($from); | 107 $show = $getOwnNamesAndSymbols($from); |
109 } | 108 } |
110 if ($hide != void 0) { | 109 if ($hide != void 0) { |
111 var hideMap = new Set($hide); | 110 var hideMap = new Set($hide); |
112 $show = $show.filter((k) => !hideMap.has(k)); | 111 $show = $show.filter((k) => !hideMap.has(k)); |
113 } | 112 } |
114 return $copyTheseProperties($to, $from, $show); | 113 return $copyTheseProperties($to, $from, $show); |
115 })()'''); | 114 })()'''); |
OLD | NEW |