Skip to content

Commit 64fc43c

Browse files
authored
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 <[email protected]>
1 parent 977edea commit 64fc43c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/RestQuery.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,11 +1066,7 @@ function includePath(config, auth, response, path, restOptions = {}) {
10661066
// Returns a list of pointers in REST format.
10671067
function findPointers(object, path) {
10681068
if (object instanceof Array) {
1069-
var answer = [];
1070-
for (var x of object) {
1071-
answer = answer.concat(findPointers(x, path));
1072-
}
1073-
return answer;
1069+
return object.map(x => findPointers(x, path)).flat();
10741070
}
10751071

10761072
if (typeof object !== 'object' || !object) {

0 commit comments

Comments
 (0)