code: function createCloseEvent(config) {
    const { code, reason, type, target } = config;
    let { wasClean } = config;
  
    if (!wasClean) {
      wasClean = code === 1000;
    }
  
    const closeEvent = new CloseEvent(type, {
      code,
      reason,
      wasClean
    });
  
    if (target) {
      closeEvent.target = target;
      closeEvent.srcElement = target;
      closeEvent.currentTarget = target;
    }
  
    return closeEvent;
  }
docs: /*
  Creates a CloseEvent object and extends it to allow full modification of
  its properties.
  
  @param {object} config - within config: type and optionally target, code, and reason