immediate-error 2.1.0 → 3.0.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.
Files changed (3) hide show
  1. package/README.md +25 -13
  2. package/index.js +61 -57
  3. package/package.json +23 -4
package/README.md CHANGED
@@ -1,13 +1,25 @@
1
- # Immediate-error
2
- This is a utility to throw an error
3
- ```javascript
4
- const immediateError = require('immediate-error')
5
- const { ERROR } = immediateError
6
- immediateError('Aaaaah') // this will throw an error with the message Aaaaah
7
- immediateError('Aaaaah', { errorType: ERROR.Error }) // does the same thing as above because by default errorType is ERROR.Error
8
- immediateError('Assertion error', { errorType: ERROR.AssertionError }) // throws an assertionerror
9
- immediateError('Range error', { errorType: ERROR.RangeError }) // throws a rangeerror
10
- immediateError('Reference error', { errorType: ERROR.ReferenceError }) // throws an referenceerror
11
- immediateError('Syntax error', { errorType: ERROR.SyntaxError }) // throws a syntaxerror
12
- immediateError('type error', { errorType: ERROR.TypeError }) // throws a typeerror
13
- ```
1
+ # Immediate-error
2
+
3
+ This is a utility to throw an error
4
+
5
+ ```javascript
6
+
7
+ const immediateError = require('immediate-error')
8
+
9
+ const { ERROR } = immediateError
10
+
11
+ immediateError('Aaaaah') // this will throw an error with the message Aaaaah
12
+
13
+ immediateError('Aaaaah', { errorType: ERROR.Error }) // does the same thing as above because by default errorType is ERROR.Error
14
+
15
+ immediateError('Assertion error', { errorType: ERROR.AssertionError }) // throws an assertionerror
16
+
17
+ immediateError('Range error', { errorType: ERROR.RangeError }) // throws a rangeerror
18
+
19
+ immediateError('Reference error', { errorType: ERROR.ReferenceError }) // throws an referenceerror
20
+
21
+ immediateError('Syntax error', { errorType: ERROR.SyntaxError }) // throws a syntaxerror
22
+
23
+ immediateError('type error', { errorType: ERROR.TypeError }) // throws a typeerror
24
+
25
+ ```
package/index.js CHANGED
@@ -1,58 +1,62 @@
1
- const ERROR = Object.freeze({
2
- Error: 0,
3
- AssertionError: 1,
4
- RangeError: 2,
5
- ReferenceError: 3,
6
- SyntaxError: 4,
7
- TypeError: 5
8
- })
9
-
10
- const assert = require('node:assert')
11
- var d = assert
12
- d = 1
13
-
14
- module.exports = function immediateError(message = 'You asked for it', options = {
15
- errorType: ERROR.Error
16
- }) {
17
- var str
18
- switch(options.errorType) {
19
- case ERROR.Error: {
20
- str = 'throw new Error(message)'
21
- break
22
- }
23
-
24
- case ERROR.AssertionError: {
25
- str = "throw new assert.AssertionError({ message })"
26
- break
27
- }
28
-
29
- case ERROR.RangeError: {
30
- str = "throw new RangeError(message)"
31
- break
32
- }
33
-
34
- case ERROR.ReferenceError: {
35
- str = "throw new ReferenceError(message)"
36
- break
37
- }
38
-
39
- case ERROR.SyntaxError: {
40
- str = "throw new SyntaxError(message)"
41
- break
42
- }
43
-
44
- case ERROR.TypeError: {
45
- str = "throw new TypeError(message)"
46
- break
47
- }
48
-
49
- default: {
50
- error = Error
51
- break
52
- }
53
- }
54
-
55
- eval(str)
56
- }
57
-
1
+ require('vanilla-javascript')
2
+ require('none')()
3
+
4
+ const ERROR = Object.freeze({
5
+ Error: 0,
6
+ AssertionError: 1,
7
+ RangeError: 2,
8
+ ReferenceError: 3,
9
+ SyntaxError: 4,
10
+ TypeError: 5
11
+ })
12
+
13
+ const assert = require('assert-fn')
14
+ var _____test_no_gray_out = assert
15
+ _____test_no_gray_out = _____test_no_gray_out
16
+
17
+ module.exports = function immediateError(message = 'You asked for it', options = {
18
+ errorType: ERROR.Error
19
+ }) {
20
+ _____test_no_gray_out = options
21
+ var str
22
+ switch(options.errorType) {
23
+ case ERROR.Error: {
24
+ str = 'throw new Error(message)'
25
+ break
26
+ }
27
+
28
+ case ERROR.AssertionError: {
29
+ str = "throw new assert.AssertionError(message)"
30
+ break
31
+ }
32
+
33
+ case ERROR.RangeError: {
34
+ str = "throw new RangeError(message)"
35
+ break
36
+ }
37
+
38
+ case ERROR.ReferenceError: {
39
+ str = "throw new ReferenceError(message)"
40
+ break
41
+ }
42
+
43
+ case ERROR.SyntaxError: {
44
+ str = "throw new SyntaxError(message)"
45
+ break
46
+ }
47
+
48
+ case ERROR.TypeError: {
49
+ str = "throw new TypeError(message)"
50
+ break
51
+ }
52
+
53
+ default: {
54
+ error = Error
55
+ break
56
+ }
57
+ }
58
+
59
+ eval(str)
60
+ }
61
+
58
62
  module.exports.ERROR = ERROR
package/package.json CHANGED
@@ -1,11 +1,30 @@
1
1
  {
2
2
  "name": "immediate-error",
3
- "version": "2.1.0",
4
- "description": "Causes an error when run.",
3
+ "version": "3.0.0",
4
+ "description": "Immediate-error",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
- "author": "tj-commits/87f",
10
- "license": "UNLICENSED"
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/tj-commits/immediate-error.git"
12
+ },
13
+ "keywords": [
14
+ "error",
15
+ "throw",
16
+ "immediate-error",
17
+ "tool"
18
+ ],
19
+ "author": "tj-commits",
20
+ "license": "UNLICENSED",
21
+ "bugs": {
22
+ "url": "https://github.com/tj-commits/immediate-error/issues"
23
+ },
24
+ "homepage": "https://github.com/tj-commits/immediate-error#readme",
25
+ "dependencies": {
26
+ "assert-fn": "^1.0.1",
27
+ "none": "^1.0.0",
28
+ "vanilla-javascript": "^1.1.1"
29
+ }
11
30
  }