diff --git a/lib/only.js b/lib/only.js index c01c74a4f..0551a3354 100644 --- a/lib/only.js +++ b/lib/only.js @@ -1,12 +1,11 @@ module.exports = (obj, keys) => { - obj = obj || {}; - if ('string' == typeof keys) keys = keys.split(/ +/); - const ret = {}; + obj = obj || {} + if (typeof keys === 'string') keys = keys.split(/ +/) + const ret = {} for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (null == obj[key]) continue; - ret[key] = obj[key]; + const key = keys[i] + if (obj[key] == null) continue + ret[key] = obj[key] } - return ret; - -}; + return ret +}