diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index eefe105..d973a5a 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -377,11 +377,8 @@ function Library (ronin) { } } - this.map = async (arr, fn) => { // Run a function on each element in a list. - for (let i = 0; i < arr.length; i++) { - const arg = arr[i] - arr[i] = await fn(arg) - } + this.map = (arr, fn) => { // Run a function on each element in a list. + return Promise.all(arr.map(fn)).then( result => { return result } ) } this.filter = (arr, fn) => { // Remove from list, when function returns false. diff --git a/examples/benchmark/general.lisp b/examples/benchmark/general.lisp index e240340..93e7faf 100644 --- a/examples/benchmark/general.lisp +++ b/examples/benchmark/general.lisp @@ -36,7 +36,7 @@ (test "range with step" (range 0 4 2) (0 2 4)) (test "range with negative step" (range 0 -4 -1) (0 -1 -2 -3 -4)) (test "map" (map (1 2 3) (λ (a) (add 1 a))) (2 3 4)) - (test "filter" (filter (2 3 4 5 6)) (λ (a) (eq 0 (mod a 2))) (2 4 6)) + (test "filter" (filter (2 3 4 5 6) (λ (a) (eq 0 (mod a 2)))) (2 4 6)) (test "reduce" (reduce (1 2 3) (λ (acc val) (add acc val)) 4) 10) ; Scope @@ -65,4 +65,4 @@ (echo (filepath)) (echo (dirpath)) (echo (file)) -(echo (dir)) \ No newline at end of file +(echo (dir))