source: imaps-frontend/node_modules/core-js/modules/esnext.error.is-error.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.4 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var getBuiltIn = require('../internals/get-built-in');
4var isObject = require('../internals/is-object');
5var classof = require('../internals/classof');
6var fails = require('../internals/fails');
7
8var ERROR = 'Error';
9var DOM_EXCEPTION = 'DOMException';
10// eslint-disable-next-line es/no-object-setprototypeof, no-proto -- safe
11var PROTOTYPE_SETTING_AVAILABLE = Object.setPrototypeOf || ({}).__proto__;
12
13var DOMException = getBuiltIn(DOM_EXCEPTION);
14var $Error = Error;
15var $isError = $Error.isError;
16
17var FORCED = !$isError || !PROTOTYPE_SETTING_AVAILABLE || fails(function () {
18 // Bun, isNativeError-based implementations, some buggy structuredClone-based implementations, etc.
19 // https://github.com/oven-sh/bun/issues/15821
20 return (DOMException && !$isError(new DOMException(DOM_EXCEPTION))) ||
21 // structuredClone-based implementations
22 // eslint-disable-next-line es/no-error-cause -- detection
23 !$isError(new $Error(ERROR, { cause: function () { /* empty */ } })) ||
24 // instanceof-based and FF Error#stack-based implementations
25 $isError(getBuiltIn('Object', 'create')($Error.prototype));
26});
27
28// `Error.isError` method
29// https://github.com/tc39/proposal-is-error
30$({ target: 'Error', stat: true, sham: true, forced: FORCED }, {
31 isError: function isError(arg) {
32 if (!isObject(arg)) return false;
33 var tag = classof(arg);
34 return tag === ERROR || tag === DOM_EXCEPTION;
35 }
36});
Note: See TracBrowser for help on using the repository browser.