1// given an input that may or may not be an object, return an object that has 2// a copy of every defined property listed in 'copy'. if the input is not an 3// object, assign it to the property named by 'wrap' 4const getOptions = (input, { copy, wrap }) => { 5 const result = {} 6 7 if (input && typeof input === 'object') { 8 for (const prop of copy) { 9 if (input[prop] !== undefined) { 10 result[prop] = input[prop] 11 } 12 } 13 } else { 14 result[wrap] = input 15 } 16 17 return result 18} 19 20module.exports = getOptions 21