-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
'use strict'; | ||
var parent = require('../../stable/error'); | ||
require('../../modules/es.object.create'); | ||
require('../../modules/esnext.error.is-error'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
require('../../modules/es.object.create'); | ||
require('../../modules/esnext.error.is-error'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Error.isError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
var parent = require('../../actual/error/is-error'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var getBuiltIn = require('../internals/get-built-in'); | ||
var isObject = require('../internals/is-object'); | ||
var classof = require('../internals/classof'); | ||
var fails = require('../internals/fails'); | ||
|
||
var ERROR = 'Error'; | ||
var DOM_EXCEPTION = 'DOMException'; | ||
// eslint-disable-next-line es/no-object-setprototypeof, no-proto -- safe | ||
var PROTOTYPE_SETTING_AVAILABLE = Object.setPrototypeOf || ({}).__proto__; | ||
|
||
var DOMException = getBuiltIn(DOM_EXCEPTION); | ||
var $Error = Error; | ||
var $isError = $Error.isError; | ||
|
||
var FORCED = !$isError || !PROTOTYPE_SETTING_AVAILABLE || fails(function () { | ||
// Bun, isNativeError-based implementations, some buggy structuredClone-based implementations, etc. | ||
// https://github.com/oven-sh/bun/issues/15821 | ||
return (DOMException && !$isError(new DOMException(DOM_EXCEPTION))) || | ||
// structuredClone-based implementations | ||
// eslint-disable-next-line es/no-error-cause -- detection | ||
!$isError(new $Error(ERROR, { cause: function () { /* empty */ } })) || | ||
// instanceof-based and FF Error#stack-based implementations | ||
$isError(getBuiltIn('Object', 'create')($Error.prototype)); | ||
}); | ||
|
||
// `Error.isError` method | ||
// https://github.com/tc39/proposal-is-error | ||
$({ target: 'Error', stat: true, sham: true, forced: FORCED }, { | ||
isError: function isError(arg) { | ||
if (!isObject(arg)) return false; | ||
var tag = classof(arg); | ||
return tag === ERROR || tag === DOM_EXCEPTION; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-is-error | ||
require('../modules/esnext.error.is-error'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters