js-on-sx: Array.prototype methods carry spec lengths + names
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
This commit is contained in:
@@ -4369,17 +4369,56 @@
|
||||
|
||||
(define js-array-of (fn (&rest args) args))
|
||||
|
||||
(define
|
||||
js-array-proto-fn-length
|
||||
(fn
|
||||
(name)
|
||||
(cond
|
||||
((= name "concat") 1)
|
||||
((= name "copyWithin") 2)
|
||||
((= name "every") 1)
|
||||
((= name "fill") 1)
|
||||
((= name "filter") 1)
|
||||
((= name "find") 1)
|
||||
((= name "findIndex") 1)
|
||||
((= name "findLast") 1)
|
||||
((= name "findLastIndex") 1)
|
||||
((= name "flat") 0)
|
||||
((= name "flatMap") 1)
|
||||
((= name "forEach") 1)
|
||||
((= name "includes") 1)
|
||||
((= name "indexOf") 1)
|
||||
((= name "join") 1)
|
||||
((= name "lastIndexOf") 1)
|
||||
((= name "map") 1)
|
||||
((= name "push") 1)
|
||||
((= name "reduce") 1)
|
||||
((= name "reduceRight") 1)
|
||||
((= name "slice") 2)
|
||||
((= name "some") 1)
|
||||
((= name "sort") 1)
|
||||
((= name "splice") 2)
|
||||
((= name "unshift") 1)
|
||||
((= name "at") 1)
|
||||
((= name "toSorted") 1)
|
||||
((= name "toReversed") 0)
|
||||
((= name "with") 2)
|
||||
(else 0))))
|
||||
|
||||
(define
|
||||
js-array-proto-fn
|
||||
(fn
|
||||
(name)
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((this-val (js-this)))
|
||||
{:__callable__
|
||||
(fn
|
||||
(&rest args)
|
||||
(let
|
||||
((recv (cond ((list? this-val) this-val) ((and (dict? this-val) (contains? (keys this-val) "length")) (js-arraylike-to-list this-val)) (else this-val))))
|
||||
(js-invoke-method recv name args))))))
|
||||
((this-val (js-this)))
|
||||
(let
|
||||
((recv (cond ((list? this-val) this-val) ((and (dict? this-val) (contains? (keys this-val) "length")) (js-arraylike-to-list this-val)) (else this-val))))
|
||||
(js-invoke-method recv name args))))
|
||||
:length (js-array-proto-fn-length name)
|
||||
:name name}))
|
||||
|
||||
(define
|
||||
js-array-from
|
||||
|
||||
Reference in New Issue
Block a user