function sanitize(data) {
  if (!isPrimitive(data) && !Array.isArray(data) && !isPlainObject(data)) {
    // handle types that will probably cause issues in
    // the structured clone
    return Object.prototype.toString.call(data);
  } else {
    return data;
  }
}
Sanitize data to be posted to the other side.
Since the message posted is sent with structured clone,
we need to filter out any types that might cause an error.

@param {*} data
@return {*}