Skip to content

Commit 0a9c05a

Browse files
authored
Merge pull request #226 from daynin/js-object
feat: provide `js-object?` and fix it
2 parents ece139e + c9a52d8 commit 0a9c05a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

racketscript-compiler/racketscript/interop.rkt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
(rename-out [*in-js-array in-js-array]
2727
[*in-js-object in-js-object])
2828
for/js-array
29-
for/js-object)
29+
js-array?
30+
for/js-object
31+
js-object?)
3032

3133
(require syntax/parse/define
3234
(for-syntax syntax/parse
@@ -252,7 +254,7 @@
252254
($ arr 'length i))
253255

254256
(define (js-array? v)
255-
($/instanceof v ($ 'Array)))
257+
(($ ($ 'Array) 'isArray) v))
256258

257259
(define (in-js-array arr)
258260
(check-array arr)
@@ -300,7 +302,7 @@
300302
(for/list ([(k v) (*in-js-object obj)]) (values k v)))
301303

302304
(define (js-object? v)
303-
($/typeof v "object"))
305+
(and ($/typeof v "object") (not (eq? v $/null))))
304306

305307
(define (check-object v)
306308
(unless (js-object? v)

0 commit comments

Comments
 (0)