UNPKG

@wesjet/function.js

Version:
20 lines (19 loc) 496 B
/** * Copyright (c) Wesbitty, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ export const pick = (obj, keys, /** Whether to filter out explicit `undefined` values */ filterUndefined = true) => { return keys.reduce((acc, key) => { const val = obj[key]; if (val === undefined && filterUndefined) return acc; acc[key] = val; return acc; }, {}); };