function convertToPlainObject(
  value,
)

 {
  if (is.isError(value)) {
    return {
      message: value.message,
      name: value.name,
      stack: value.stack,
      ...getOwnProperties(value),
    };
  } else if (is.isEvent(value)) {
    const newObj

 = {
      type: value.type,
      target: serializeEventTarget(value.target),
      currentTarget: serializeEventTarget(value.currentTarget),
      ...getOwnProperties(value),
    };

    if (typeof CustomEvent !== 'undefined' && is.isInstanceOf(value, CustomEvent)) {
      newObj.detail = value.detail;
    }

    return newObj;
  } else {
    return value;
  }
}
Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their
non-enumerable properties attached.

@param value Initial source that we have to transform in order for it to be usable by the serializer
@returns An Event or Error turned into an object - or the value argurment itself, when value is neither an Event nor
 an Error.