#lang scheme/base
(require scheme/contract
(file "struct.ss"))
(define (javascript-array->list arr)
(ArrayLiteral-elements arr))
(define (javascript-object->alist obj)
(map (lambda (kvp)
(let ([key (car kvp)]
[val (cdr kvp)])
(cons (cond [(Identifier? key) (Identifier-name key)]
[(StringLiteral? key) (StringLiteral-value key)]
[(NumericLiteral? key) (NumericLiteral-value key)])
val)))
(ObjectLiteral-properties obj)))
(provide/contract
[javascript-array->list (-> ArrayLiteral? (listof Expression?))]
[javascript-object->alist (-> ObjectLiteral? (listof (cons/c (or/c symbol? string? number?) Expression?)))])