<commit_before>/**
 * @fileoverview Utility functions for the demo app.
 *
 */
import {store} from '../store/store.js';

/**
 * Create a deep copy of the passed in data, which is expected
 * to be shaped like the sample data in store.js.
 * @param {!Object} data The data to copy.
 * @return {!Object} A deep copy of the input.
 */
export function deepCopy(data) {
  return JSON.parse(JSON.stringify(data));
}

/**
 * Type definition for our application's standard item parameters.
 * These are to be sent in the items array found in many gtag events.
 * Acceptable parameters can be [found here](https://developers.google.com/gtagjs/reference/aw-events)
 * @typedef {{item_id: string, item_name: string,
  *     value: string}} ItemParameters
  */

/**
  * Selects an item from the store via ID and returns an object containing
  * its standard item parameters.
  * @param {string} itemId
  * @return {!ItemParameters}
  */
export function getItemParameters(itemId) {
  const /** {ItemStore} */ items = store.getState().items;
  return {
    item_id: itemId,
    item_name: items[itemId].name,
    value: items[itemId].cost,
  };
}

/**
  * Collects all the standard item parameters from the items in the cart
  * and returns them in an array.
  * @return {Array<!ItemParameters>}
  */
export function getItemsArrayFromCart() {
  const /** Array<!ItemParameters> */ itemsArray = [];
  const items = store.getState().items;
  for (const [itemID, item] of Object.entries(items)) {
    if (item.inCart) {
      itemsArray.push(getItemParameters(itemID));
    }
  }
  return itemsArray;
}
<commit_msg>Change some params to reflect latest guidance<commit_after>/**
 * @fileoverview Utility functions for the demo app.
 *
 */
import {store} from '../store/store.js';

/**
 * Create a deep copy of the passed in data, which is expected
 * to be shaped like the sample data in store.js.
 * @param {!Object} data The data to copy.
 * @return {!Object} A deep copy of the input.
 */
export function deepCopy(data) {
  return JSON.parse(JSON.stringify(data));
}

/**
 * Type definition for our application's standard item parameters.
 * These are to be sent in the items array found in many gtag events.
 * Acceptable parameters can be [found here](https://developers.google.com/gtagjs/reference/aw-events)
 * @typedef {{item_id: string, item_name: string,
  *     price: string}} ItemParameters
  */

/**
  * Selects an item from the store via ID and returns an object containing
  * its standard item parameters.
  * @param {string} itemId
  * @return {!ItemParameters}
  */
export function getItemParameters(itemId) {
  const /** {ItemStore} */ items = store.getState().items;
  return {
    item_id: itemId,
    item_name: items[itemId].name,
    price: items[itemId].cost,
  };
}

/**
  * Collects all the standard item parameters from the items in the cart
  * and returns them in an array.
  * @return {Array<!ItemParameters>}
  */
export function getItemsArrayFromCart() {
  const /** Array<!ItemParameters> */ itemsArray = [];
  const items = store.getState().items;
  for (const [itemID, item] of Object.entries(items)) {
    if (item.inCart) {
      itemsArray.push({
        ...getItemParameters(itemID),
        quantity: item.quantity,
      });
    }
  }
  return itemsArray;
}

{'fraction_non_alphanumeric': 0.12397197685044167, 'fraction_numerical': 0.0, 'mean_word_length': 3.517193947730399, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3051082', 'n_tokens_mistral': 990, 'n_tokens_neox': 976, 'n_words': 339}