From e798df95f26d6dda2f153adfdfa30df7938f44b4 Mon Sep 17 00:00:00 2001 From: RTLcoil Date: Fri, 24 Jul 2020 19:49:35 +0300 Subject: [PATCH] Refactor `pickOnlyExistingValues()` function --- lib-es5/utils/index.js | 5 ++--- lib/utils/index.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib-es5/utils/index.js b/lib-es5/utils/index.js index 3366a75d..74a3ba8d 100644 --- a/lib-es5/utils/index.js +++ b/lib-es5/utils/index.js @@ -1463,12 +1463,11 @@ function pickOnlyExistingValues(source) { keys[_key2 - 1] = arguments[_key2]; } - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; + keys.forEach(function (key) { if (source[key] != null) { result[key] = source[key]; } - } + }); } return result; } diff --git a/lib/utils/index.js b/lib/utils/index.js index b41190ba..ee3b242f 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -1333,12 +1333,11 @@ function present(value) { function pickOnlyExistingValues(source, ...keys) { let result = {}; if (source) { - for (let j = 0; j < keys.length; j++) { - let key = keys[j]; + keys.forEach((key) => { if (source[key] != null) { result[key] = source[key]; } - } + }); } return result; }