OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_helper; | 5 part of dart._js_helper; |
6 | 6 |
7 // TODO(leafp): Maybe get rid of this? Currently used by the interceptors | 7 // TODO(leafp): Maybe get rid of this? Currently used by the interceptors |
8 // library, but that should probably be culled as well. | 8 // library, but that should probably be culled as well. |
9 Type getRuntimeType(var object) => | 9 Type getRuntimeType(var object) => |
10 JS('Type|null', 'dart.realRuntimeType(#)', object); | 10 JS('Type|null', 'dart.realRuntimeType(#)', object); |
11 | 11 |
12 /// Returns the property [index] of the JavaScript array [array]. | 12 /// Returns the property [index] of the JavaScript array [array]. |
13 getIndex(var array, int index) { | 13 getIndex(var array, int index) { |
14 assert(isJsArray(array)); | 14 assert_(isJsArray(array)); |
15 return JS('var', r'#[#]', array, index); | 15 return JS('var', r'#[#]', array, index); |
16 } | 16 } |
17 | 17 |
18 /// Returns the length of the JavaScript array [array]. | 18 /// Returns the length of the JavaScript array [array]. |
19 int getLength(var array) { | 19 int getLength(var array) { |
20 assert(isJsArray(array)); | 20 assert_(isJsArray(array)); |
21 return JS('int', r'#.length', array); | 21 return JS('int', r'#.length', array); |
22 } | 22 } |
23 | 23 |
24 /// Returns whether [value] is a JavaScript array. | 24 /// Returns whether [value] is a JavaScript array. |
25 bool isJsArray(var value) { | 25 bool isJsArray(var value) { |
26 return value is JSArray; | 26 return value is JSArray; |
27 } | 27 } |
OLD | NEW |