File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ intrinsics! {
95
95
#[ symbol = "__wbindgen_is_function" ]
96
96
#[ signature = fn ( ref_externref( ) ) -> Boolean ]
97
97
IsFunction ,
98
+ #[ symbol = "__wbindgen_is_array" ]
99
+ #[ signature = fn ( ref_externref( ) ) -> Boolean ]
100
+ IsArray ,
98
101
#[ symbol = "__wbindgen_is_undefined" ]
99
102
#[ signature = fn ( ref_externref( ) ) -> Boolean ]
100
103
IsUndefined ,
Original file line number Diff line number Diff line change @@ -3141,6 +3141,11 @@ impl<'a> Context<'a> {
3141
3141
format ! ( "typeof({}) === 'function'" , args[ 0 ] )
3142
3142
}
3143
3143
3144
+ Intrinsic :: IsArray => {
3145
+ assert_eq ! ( args. len( ) , 1 ) ;
3146
+ format ! ( "Array.isArray({})" , args[ 0 ] )
3147
+ }
3148
+
3144
3149
Intrinsic :: IsUndefined => {
3145
3150
assert_eq ! ( args. len( ) , 1 ) ;
3146
3151
format ! ( "{} === undefined" , args[ 0 ] )
Original file line number Diff line number Diff line change @@ -348,6 +348,12 @@ impl JsValue {
348
348
unsafe { __wbindgen_is_object ( self . idx ) == 1 }
349
349
}
350
350
351
+ /// Tests whether this JS value is an instance of Array.
352
+ #[ inline]
353
+ pub fn is_array ( & self ) -> bool {
354
+ unsafe { __wbindgen_is_array ( self . idx ) == 1 }
355
+ }
356
+
351
357
/// Tests whether the type of this JS value is `function`.
352
358
#[ inline]
353
359
pub fn is_function ( & self ) -> bool {
@@ -1003,6 +1009,7 @@ externs! {
1003
1009
fn __wbindgen_is_undefined( idx: u32 ) -> u32 ;
1004
1010
fn __wbindgen_is_symbol( idx: u32 ) -> u32 ;
1005
1011
fn __wbindgen_is_object( idx: u32 ) -> u32 ;
1012
+ fn __wbindgen_is_array( idx: u32 ) -> u32 ;
1006
1013
fn __wbindgen_is_function( idx: u32 ) -> u32 ;
1007
1014
fn __wbindgen_is_string( idx: u32 ) -> u32 ;
1008
1015
fn __wbindgen_is_bigint( idx: u32 ) -> u32 ;
Original file line number Diff line number Diff line change 3
3
use std:: convert:: TryFrom ;
4
4
use std:: fmt:: Debug ;
5
5
6
- use js_sys:: { Object , RangeError , Reflect } ;
6
+ use js_sys:: { Array , Object , RangeError , Reflect } ;
7
7
use wasm_bindgen:: { JsCast , JsValue } ;
8
8
use wasm_bindgen_test:: wasm_bindgen_test;
9
9
@@ -78,6 +78,7 @@ fn types() {
78
78
assert ! ( JsValue :: UNDEFINED . is_undefined( ) ) ;
79
79
assert ! ( JsValue :: NULL . is_null( ) ) ;
80
80
assert ! ( Object :: new( ) . is_object( ) ) ;
81
+ assert ! ( Array :: new( ) . is_array( ) ) ;
81
82
assert ! ( JsValue :: symbol( None ) . is_symbol( ) ) ;
82
83
assert ! ( JsValue :: from_str( "hi" ) . is_string( ) ) ;
83
84
assert ! ( JsValue :: bigint_from_str( "5" ) . is_bigint( ) ) ;
You can’t perform that action at this time.
0 commit comments