123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- Object.defineProperty(exports, '__esModule', { value: true });
- // eslint-disable-next-line @typescript-eslint/unbound-method
- const objectToString = Object.prototype.toString;
- /**
- * Checks whether given value's type is one of a few Error or Error-like
- * {@link isError}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isError(wat) {
- switch (objectToString.call(wat)) {
- case '[object Error]':
- case '[object Exception]':
- case '[object DOMException]':
- return true;
- default:
- return isInstanceOf(wat, Error);
- }
- }
- /**
- * Checks whether given value is an instance of the given built-in class.
- *
- * @param wat The value to be checked
- * @param className
- * @returns A boolean representing the result.
- */
- function isBuiltin(wat, className) {
- return objectToString.call(wat) === `[object ${className}]`;
- }
- /**
- * Checks whether given value's type is ErrorEvent
- * {@link isErrorEvent}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isErrorEvent(wat) {
- return isBuiltin(wat, 'ErrorEvent');
- }
- /**
- * Checks whether given value's type is DOMError
- * {@link isDOMError}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isDOMError(wat) {
- return isBuiltin(wat, 'DOMError');
- }
- /**
- * Checks whether given value's type is DOMException
- * {@link isDOMException}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isDOMException(wat) {
- return isBuiltin(wat, 'DOMException');
- }
- /**
- * Checks whether given value's type is a string
- * {@link isString}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isString(wat) {
- return isBuiltin(wat, 'String');
- }
- /**
- * Checks whether given string is parameterized
- * {@link isParameterizedString}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isParameterizedString(wat) {
- return (
- typeof wat === 'object' &&
- wat !== null &&
- '__sentry_template_string__' in wat &&
- '__sentry_template_values__' in wat
- );
- }
- /**
- * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
- * {@link isPrimitive}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isPrimitive(wat) {
- return wat === null || isParameterizedString(wat) || (typeof wat !== 'object' && typeof wat !== 'function');
- }
- /**
- * Checks whether given value's type is an object literal, or a class instance.
- * {@link isPlainObject}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isPlainObject(wat) {
- return isBuiltin(wat, 'Object');
- }
- /**
- * Checks whether given value's type is an Event instance
- * {@link isEvent}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isEvent(wat) {
- return typeof Event !== 'undefined' && isInstanceOf(wat, Event);
- }
- /**
- * Checks whether given value's type is an Element instance
- * {@link isElement}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isElement(wat) {
- return typeof Element !== 'undefined' && isInstanceOf(wat, Element);
- }
- /**
- * Checks whether given value's type is an regexp
- * {@link isRegExp}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isRegExp(wat) {
- return isBuiltin(wat, 'RegExp');
- }
- /**
- * Checks whether given value has a then function.
- * @param wat A value to be checked.
- */
- function isThenable(wat) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- return Boolean(wat && wat.then && typeof wat.then === 'function');
- }
- /**
- * Checks whether given value's type is a SyntheticEvent
- * {@link isSyntheticEvent}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isSyntheticEvent(wat) {
- return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
- }
- /**
- * Checks whether given value is NaN
- * {@link isNaN}.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isNaN(wat) {
- return typeof wat === 'number' && wat !== wat;
- }
- /**
- * Checks whether given value's type is an instance of provided constructor.
- * {@link isInstanceOf}.
- *
- * @param wat A value to be checked.
- * @param base A constructor to be used in a check.
- * @returns A boolean representing the result.
- */
- function isInstanceOf(wat, base) {
- try {
- return wat instanceof base;
- } catch (_e) {
- return false;
- }
- }
- /**
- * Checks whether given value's type is a Vue ViewModel.
- *
- * @param wat A value to be checked.
- * @returns A boolean representing the result.
- */
- function isVueViewModel(wat) {
- // Not using Object.prototype.toString because in Vue 3 it would read the instance's Symbol(Symbol.toStringTag) property.
- return !!(typeof wat === 'object' && wat !== null && ((wat ).__isVue || (wat )._isVue));
- }
- exports.isDOMError = isDOMError;
- exports.isDOMException = isDOMException;
- exports.isElement = isElement;
- exports.isError = isError;
- exports.isErrorEvent = isErrorEvent;
- exports.isEvent = isEvent;
- exports.isInstanceOf = isInstanceOf;
- exports.isNaN = isNaN;
- exports.isParameterizedString = isParameterizedString;
- exports.isPlainObject = isPlainObject;
- exports.isPrimitive = isPrimitive;
- exports.isRegExp = isRegExp;
- exports.isString = isString;
- exports.isSyntheticEvent = isSyntheticEvent;
- exports.isThenable = isThenable;
- exports.isVueViewModel = isVueViewModel;
- //# sourceMappingURL=is.js.map
|