immediate-error 5.1.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,8 @@ immediateError('Aaaaah') // this will throw a regular Error with the message "Aa
12
12
 
13
13
  immediateError('Aaaaah', ErrorType.BaseError) // does the same thing as above
14
14
 
15
+ immediateError('Aggregate error', ErrorType.AggregateError) // throws an AggregateError
16
+
15
17
  immediateError('Assertion error', ErrorType.AssertionError) // throws an AssertionError (from the assert-fn module)
16
18
 
17
19
  immediateError('Assertion error', ErrorType.NativeAssertionError) // throws an AssertionError (from the node:assert module)
package/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  export enum ErrorType {
2
2
  BaseError = 0,
3
- AssertionError = 1,
4
- RangeError = 2,
5
- ReferenceError = 3,
6
- SyntaxError = 4,
7
- TypeError = 5,
8
- NativeAssertionError = 6
3
+ AggregateError = 1,
4
+ AssertionError = 2,
5
+ RangeError = 3,
6
+ ReferenceError = 4,
7
+ SyntaxError = 5,
8
+ TypeError = 6,
9
+ NativeAssertionError = 7
9
10
  }
10
11
 
11
12
  export function immediateError(message?: string, errorType?: ErrorType | Function): void
package/index.js CHANGED
@@ -2,12 +2,15 @@ require('vanilla-javascript')
2
2
  require('none')()
3
3
 
4
4
  const esmRequire = require('esm-wallaby')(module)
5
+ const GetIntrinsic = require('get-intrinsic')
6
+ const zero = require('number-zero')
5
7
  const one = require('the-number-one').default
6
8
  const two = require('two')
7
9
  const three = require('numeric-constant-three')
8
10
  const four = require('always-four')
9
11
  const five = require('five')
10
12
  const six = require('number-six')
13
+ const seven = require('se7en')
11
14
  const { throwop } = require('yanoop')
12
15
  const throwError = require('throw-error')
13
16
  const bail = esmRequire('bail').bail
@@ -20,6 +23,7 @@ const vm = require('node:vm')
20
23
 
21
24
  const $BaseError = require('es-errors')
22
25
  const $AssertionError = assert.AssertionError
26
+ const $AggregateError = GetIntrinsic('%AggregateError%')
23
27
  const $RangeError = require('es-errors/range')
24
28
  const $ReferenceError = require('es-errors/ref')
25
29
  const $SyntaxError = require('es-errors/syntax')
@@ -27,13 +31,14 @@ const $TypeError = require('es-errors/type')
27
31
  const $NativeAssertionError = nativeAssert.AssertionError
28
32
 
29
33
  const ERROR = Object.freeze({
30
- BaseError:0,
34
+ BaseError:zero,
31
35
  AssertionError: one,
32
- RangeError: two(),
33
- ReferenceError: three(),
34
- SyntaxError: four(),
35
- TypeError: five(),
36
- NativeAssertionError: six()
36
+ AggregateError: two(),
37
+ RangeError: three(),
38
+ ReferenceError: four(),
39
+ SyntaxError: five(),
40
+ TypeError: six(),
41
+ NativeAssertionError: seven()
37
42
  })
38
43
 
39
44
  exports.immediateError = function immediateError(message = 'ERROR!', errorType = ERROR.Error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "immediate-error",
3
- "version": "5.1.1",
3
+ "version": "6.1.0",
4
4
  "description": "Throw errors, better.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,10 +29,12 @@
29
29
  "es-errors": "^1.3.0",
30
30
  "esm-wallaby": "^3.2.30",
31
31
  "five": "^0.8.0",
32
+ "get-intrinsic": "^1.3.0",
32
33
  "if": "^2.0.0",
33
34
  "is-error": "^2.2.2",
34
35
  "none": "^1.0.0",
35
36
  "number-six": "^1.0.1",
37
+ "number-zero": "^1.0.3",
36
38
  "numeric-constant-three": "^1.0.0",
37
39
  "picocolors": "^1.1.1",
38
40
  "the-number-one": "^1.0.1",