// declare functions for all the different types of embeds as shown previously

const Types = {
  youtube,
  vimeo,
  vine,
  twitter,
  facebook,
  instagram,
  iframe
};

export const load = (node = document) => {
  const $nodes = $(node).find('[data-embed-loaded=false]');
  $nodes.each(function () {
    const $this = $(this);
    const type = $this.data('embed-type');
    if (Types.hasOwnProperty(type)) {
      Types[type]($this);
    }
    $this.attr(loadedAttr, 'true');
  });
};