1a535f946e56f26b0d0b8e299e15085f2e9f11f7f0ae69816466f1e93565cc641e7600a659f8c6c48c35e7c02899918aefd61fa8e40efe715b5826835dd005 528 B

1234567891011121314151617181920
  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'
  4. const getOptions = (input, { copy, wrap }) => {
  5. const result = {}
  6. if (input && typeof input === 'object') {
  7. for (const prop of copy) {
  8. if (input[prop] !== undefined) {
  9. result[prop] = input[prop]
  10. }
  11. }
  12. } else {
  13. result[wrap] = input
  14. }
  15. return result
  16. }
  17. module.exports = getOptions