'use strict';

/**
 * Prefix an object's keys with "data-" for use as data attributes.
 */
function toDataAttributes(data, pick) {
  let dataAttributes = {};
  for (let key in data) {
    if (!pick || pick.has(key)) {
      dataAttributes[`data-${key.replace(/[A-Z]/g, char => `-${char.toLowerCase()}`)}`] = data[key];
    }
  }
  return dataAttributes;
}

exports.toDataAttributes = toDataAttributes;
