import {getField} from "./getField";

/**
  * Creates a new object whose fields are either equal to obj[field]
  * or defaultValue.
  * Useful for extracting a subset of fields from an object.
  *
  * @param obj the object to query the fields for.
  * @param fields an array of the target fields, in string form.
  * @param defaultValue the value to be used if obj[field] === undefined.
 */
export const getFields = (obj, fields, defaultValue) => {
  const res = {};
  for (const field of fields) { 
    res[field] = getField(obj, field, defaultValue);
  }
  return res;
}

@@ -35,17 +35,16 @@
 %22;%0A%0A/**%0A
- 
  * Creat
@@ -103,17 +103,16 @@
 %5Bfield%5D%0A
- 
  * or de
@@ -123,17 +123,16 @@
 tValue.%0A
- 
  * Usefu
@@ -187,13 +187,11 @@
 ct.%0A
- 
  *%0A
- 
  * @
@@ -236,17 +236,16 @@
 ds for.%0A
- 
  * @para
@@ -300,17 +300,16 @@
 g form.%0A
- 
  * @para
@@ -373,16 +373,155 @@
 efined.%0A
+ * @deprecated extracting values with destructuring instead.%0A * @see %7B@link https://github.com/googleinterns/step240-2020/pull/139%7CGitHub%7D%0A
  */%0Aexpo

Add deprecating comment ot getFields