'use strict';

/**
 * Returns the global `document` object if it exists, otherwise returns `undefined`.
 *
 * @returns {Nullable<Document>} Document object or `undefined`.
 */
function tryGetDocument() {
  // eslint-disable-next-line no-restricted-globals
  return typeof document !== 'undefined' ? document : undefined;
}

exports.tryGetDocument = tryGetDocument;
