source: frontend/node_modules/core-js-pure/modules/es.error.cause.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.7 KB
Line 
1'use strict';
2/* eslint-disable no-unused-vars -- required for functions `.length` */
3var $ = require('../internals/export');
4var globalThis = require('../internals/global-this');
5var apply = require('../internals/function-apply');
6var wrapErrorConstructorWithCause = require('../internals/wrap-error-constructor-with-cause');
7
8var WEB_ASSEMBLY = 'WebAssembly';
9var WebAssembly = globalThis[WEB_ASSEMBLY];
10
11// eslint-disable-next-line es/no-error-cause -- feature detection
12var FORCED = new Error('e', { cause: 7 }).cause !== 7;
13
14var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
15 var O = {};
16 // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
17 O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
18 $({ global: true, constructor: true, arity: 1, forced: FORCED }, O);
19};
20
21var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
22 if (WebAssembly && WebAssembly[ERROR_NAME]) {
23 var O = {};
24 // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
25 O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
26 $({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED }, O);
27 }
28};
29
30// https://tc39.es/ecma262/#sec-nativeerror
31exportGlobalErrorCauseWrapper('Error', function (init) {
32 return function Error(message) { return apply(init, this, arguments); };
33});
34exportGlobalErrorCauseWrapper('EvalError', function (init) {
35 return function EvalError(message) { return apply(init, this, arguments); };
36});
37exportGlobalErrorCauseWrapper('RangeError', function (init) {
38 return function RangeError(message) { return apply(init, this, arguments); };
39});
40exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
41 return function ReferenceError(message) { return apply(init, this, arguments); };
42});
43exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
44 return function SyntaxError(message) { return apply(init, this, arguments); };
45});
46exportGlobalErrorCauseWrapper('TypeError', function (init) {
47 return function TypeError(message) { return apply(init, this, arguments); };
48});
49exportGlobalErrorCauseWrapper('URIError', function (init) {
50 return function URIError(message) { return apply(init, this, arguments); };
51});
52exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
53 return function CompileError(message) { return apply(init, this, arguments); };
54});
55exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
56 return function LinkError(message) { return apply(init, this, arguments); };
57});
58exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
59 return function RuntimeError(message) { return apply(init, this, arguments); };
60});
Note: See TracBrowser for help on using the repository browser.