From 64fc43c0810680ce5b3bb03d5419beb0167a9c38 Mon Sep 17 00:00:00 2001 From: Yechezkel Deren Date: Mon, 11 Sep 2023 15:56:15 +0300 Subject: [PATCH 1/2] Update RestQuery.js Code change for performances. Instead of creating and updating the answer array on each iterations, use map function. Signed-off-by: Yechezkel Deren --- src/RestQuery.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/RestQuery.js b/src/RestQuery.js index 538d87d4c1..15f86353f0 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -1066,11 +1066,7 @@ function includePath(config, auth, response, path, restOptions = {}) { // Returns a list of pointers in REST format. function findPointers(object, path) { if (object instanceof Array) { - var answer = []; - for (var x of object) { - answer = answer.concat(findPointers(x, path)); - } - return answer; + return object.map(x => findPointers(x, path)).flat(); } if (typeof object !== 'object' || !object) { From b596a9d01d0804657f4dfffb09b29c76f223a8e8 Mon Sep 17 00:00:00 2001 From: Yechezkel Deren Date: Mon, 11 Sep 2023 17:27:30 +0300 Subject: [PATCH 2/2] remove trailing space Signed-off-by: Yechezkel Deren --- src/RestQuery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RestQuery.js b/src/RestQuery.js index 15f86353f0..96a52ec17a 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -1066,7 +1066,7 @@ function includePath(config, auth, response, path, restOptions = {}) { // Returns a list of pointers in REST format. function findPointers(object, path) { if (object instanceof Array) { - return object.map(x => findPointers(x, path)).flat(); + return object.map(x => findPointers(x, path)).flat(); } if (typeof object !== 'object' || !object) {