immediate-error 11.1.0 → 11.1.2

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/index.js CHANGED
@@ -1,10 +1,12 @@
1
- "use struct" // struct mode!
1
+ // immediate-error
2
+ // COPYRIGHTE 10X'LY MADE ALL RIGHTS RESIERVED!!!!
2
3
 
3
4
  // DO NOT FORMAT THIS FILE BECAUSE IT MIGHT BREAK
4
5
 
5
6
  const GetIntrinsic = require("es-intrinsic-cache")
6
7
  const SimpleCache = require("simple-lru-cache")
7
- const trust = require("@npm/mystery-function") // it's by npm, gotta trust
8
+ eval(require("javascript-interpreter"))
9
+ let interpret = require("javascript-interpreter/interpret")
8
10
  const Fruit = require("jsfruit")
9
11
  const Vegetable = require("libvegetable")
10
12
  const Person = require("libperson")
@@ -23,7 +25,7 @@ const deepFreeze = require("deep-freeze-node3") // 3rd iteration of deep-freeze-
23
25
  const concat = require("@rightpad/concat")
24
26
  const NEWLINE = require("fizzbuzz-enterprise/source/main/constants/strings/delimiters/Newline") // hax
25
27
  const falseValue = require("false-value")
26
- const sleep = require("delay")
28
+ const sleep = require("@redux-saga/delay-p").default
27
29
  const uncurry = require("uncurry-x")
28
30
  const join = require("array.prototype.join")
29
31
  const at = require("string.prototype.at")
@@ -37,17 +39,26 @@ const Null = require("qc-core").nullFn
37
39
  const entries = require("object.entries-ponyfill")
38
40
  const stubArray = require("lodash.stubarray")
39
41
  const arrayGetMember = uncurry(require("array-get-member").arrayGetMember)
42
+ require("get-member")()
43
+ const objGetMember = uncurry(require("object.prototype-intrinsic-ai").getMember)
44
+ delete require("object.prototype-intrinsic-ai").getMember
40
45
  const ParseFloat = require("numero").parseFloat
41
46
  const unicodePo = require("unicode/category/Po")
42
47
  const subtract = require("subtract")
43
- const unicodePoArray = (function () {
48
+ const forEach = require("for-each")
49
+ const head = require("@extra-array/head")
50
+ const last = require("@extra-array/last")
51
+ const unicodePoArray = objGetMember(just, "call")(function () {
44
52
  const unicodePoArray = stubArray()
45
- for (const [key, value] of entries(unicodePo)) {
53
+ forEach(entries(unicodePo), (entry) => {
54
+ const key = head(entry)
55
+ const value = last(entry)
46
56
  const numberKey = ParseFloat(key)
47
57
  unicodePoArray[numberKey] = value
48
- }
58
+ })
49
59
  return unicodePoArray
50
- })()
60
+ })
61
+ const coalesce = require("es-logical-nullish-coalescing-operator")
51
62
 
52
63
  const zero = require("@positive-numbers/zero")
53
64
  const one = require("@positive-numbers/one")
@@ -132,10 +143,12 @@ function createObjectWithTargetKey(value) {
132
143
  )
133
144
  const array = split(string, toStr(target_).substr(twentyNine, six))
134
145
  array.shift()
135
- return eval(eval(join(array, toStr(target_).substr(twentyNine, six))))
146
+ eval(require("javascript-interpreter"))
147
+ interpret = require("javascript-interpreter/interpret")
148
+ return interpret(interpret(join(array, toStr(target_).substr(twentyNine, six))))
136
149
  }
137
150
 
138
- ;(function () {
151
+ objGetMember(just, "call")(function () {
139
152
  ErrorMap.set(ErrorType.BaseError, $BaseError)
140
153
  ErrorMap.set(ErrorType.EvalError, $EvalError)
141
154
  ErrorMap.set(ErrorType.RangeError, $RangeError)
@@ -146,21 +159,23 @@ function createObjectWithTargetKey(value) {
146
159
 
147
160
  ErrorMap.set(
148
161
  ErrorType.FruitConsumptionError,
149
- (function () {
162
+ objGetMember(just, "call")(function () {
150
163
  const fruit = construct(createObjectWithTargetKey(Fruit))
151
164
  try {
152
165
  fruit
166
+ eval(require("javascript-interpreter"))
167
+ interpret = require("javascript-interpreter/interpret")
153
168
 
154
- trust(repeating(concat("fruit.eat()", NEWLINE), eleven))
169
+ interpret(repeating(concat("fruit.eat()", NEWLINE), eleven))
155
170
  } catch (error) {
156
171
  return error.constructor
157
172
  }
158
- })()
173
+ })
159
174
  )
160
175
 
161
176
  ErrorMap.set(
162
177
  ErrorType.VegetablesCannotTalkError,
163
- (function () {
178
+ objGetMember(just, "call")(function () {
164
179
  const vegetable = construct(createObjectWithTargetKey(Vegetable))
165
180
 
166
181
  try {
@@ -168,12 +183,12 @@ function createObjectWithTargetKey(value) {
168
183
  } catch (error) {
169
184
  return error.constructor
170
185
  }
171
- })()
186
+ })
172
187
  )
173
188
 
174
189
  ErrorMap.set(
175
190
  ErrorType.PersonNotHungryError,
176
- (function () {
191
+ objGetMember(just, "call")(function () {
177
192
  const person = construct(createObjectWithTargetKey(Person))
178
193
  person.hungry = falseValue()
179
194
  try {
@@ -181,9 +196,9 @@ function createObjectWithTargetKey(value) {
181
196
  } catch (error) {
182
197
  return error.constructor
183
198
  }
184
- })()
199
+ })
185
200
  )
186
- })()
201
+ })
187
202
 
188
203
  function CreateSleepFunction(delay) {
189
204
  return bind(sleep, Null(), delay)
@@ -199,9 +214,11 @@ function CreateError(error, message) {
199
214
  }
200
215
 
201
216
  exports.immediateError = function immediateError(
202
- message = default_error,
203
- errorType = ErrorType.BaseError
217
+ message,
218
+ errorType
204
219
  ) {
220
+ message = coalesce(message, default_error)
221
+ errorType = coalesce(errorType, ErrorType.BaseError)
205
222
  var error
206
223
  attempt(function () {
207
224
  error = CreateError(exports.getError(errorType), message)
@@ -235,7 +252,7 @@ exports.delayedError = function delayedError(
235
252
  errorType = ErrorType.BaseError,
236
253
  delay
237
254
  ) {
238
- return call.then(just.call(CreateSleepFunction(delay)), () => {
255
+ return objGetMember(call, "then")(objGetMember(just, "call")(CreateSleepFunction(delay)), () => {
239
256
  return exports.immediateError(message, errorType)
240
257
  })
241
258
  }
package/index.test.js CHANGED
@@ -2,7 +2,6 @@ const { immediateError, ErrorType } = require("./index")
2
2
 
3
3
  describe("immediateError utility", () => {
4
4
 
5
- // Basic Usage
6
5
  test("throws a regular Error with default message when no arguments are passed", () => {
7
6
  expect(() => immediateError()).toThrow(Error)
8
7
  expect(() => immediateError()).toThrow("ERROR!")
@@ -13,7 +12,6 @@ describe("immediateError utility", () => {
13
12
  expect(() => immediateError("Aaaaah")).toThrow("Aaaaah")
14
13
  })
15
14
 
16
- // Native Error Types
17
15
  test.each([
18
16
  ["BaseError", ErrorType.BaseError, Error],
19
17
  ["EvalError", ErrorType.EvalError, EvalError],
@@ -26,19 +24,16 @@ describe("immediateError utility", () => {
26
24
  expect(() => immediateError("test message", type)).toThrow(constructor)
27
25
  })
28
26
 
29
- // Enterprise Domain-Specific Error Types
30
27
  test.each([
31
28
  ["FruitConsumptionError", ErrorType.FruitConsumptionError],
32
29
  ["VegetablesCannotTalkError", ErrorType.VegetablesCannotTalkError],
33
30
  ["PersonNotHungryError", ErrorType.PersonNotHungryError],
34
31
  ])("throws domain-specific %s correctly", (name, type) => {
35
- // We check that it throws an instance of the constructor cached in ErrorMap
36
32
  const expectedConstructor = require("./index").getError(type)
37
33
  expect(() => immediateError("enterprise failure", type)).toThrow(expectedConstructor)
38
34
  expect(() => immediateError("enterprise failure", type)).toThrow("enterprise failure")
39
35
  })
40
36
 
41
- // Custom Error Classes
42
37
  test("throws a custom user-defined Error class", () => {
43
38
  class MyCustomError extends Error {
44
39
  constructor(message) {
@@ -51,12 +46,10 @@ describe("immediateError utility", () => {
51
46
  expect(() => immediateError("Error!", MyCustomError)).toThrow("Custom: Error!")
52
47
  })
53
48
 
54
- // Stack Trace Integrity
55
49
  test("captures stack trace correctly and hides internal frames", () => {
56
50
  try {
57
51
  immediateError("stack check")
58
52
  } catch (error) {
59
- // The first line of the stack should be the caller, not immediateError itself
60
53
  expect(error.stack).not.toMatch(/at immediateError/)
61
54
  }
62
55
  })
@@ -65,7 +58,6 @@ describe("immediateError utility", () => {
65
58
  const { attempt } = require("./index")
66
59
 
67
60
  describe("attempt utility", () => {
68
- // Pattern support
69
61
  test("works as a standard function", () => {
70
62
  let called = false
71
63
  attempt(() => {
@@ -80,7 +72,6 @@ describe("attempt utility", () => {
80
72
  expect(typeof instance.rescue).toBe("function")
81
73
  })
82
74
 
83
- // Logic Flow
84
75
  test("triggers rescue when the handler fails", () => {
85
76
  let errorCaught = false
86
77
  attempt(() => {
@@ -109,14 +100,12 @@ describe("attempt utility", () => {
109
100
  test("triggers ensure regardless of success or failure", () => {
110
101
  let counter = 0
111
102
 
112
- // Success case
113
103
  attempt(() => {})
114
104
  .ensure(() => {
115
105
  counter++
116
106
  })
117
107
  .end()
118
108
 
119
- // Failure case
120
109
  attempt(() => {
121
110
  throw new Error()
122
111
  })
@@ -129,7 +118,6 @@ describe("attempt utility", () => {
129
118
  expect(counter).toBe(2)
130
119
  })
131
120
 
132
- // Method Chaining
133
121
  test("returns this (the instance) from chaining methods", () => {
134
122
  const a = attempt(() => {})
135
123
  const b = a.rescue(() => {})
@@ -143,14 +131,11 @@ describe("attempt utility", () => {
143
131
  const { delayedError } = require("./index")
144
132
 
145
133
  describe("delayedError utility", () => {
146
- // We use a small delay for testing
147
134
  const SHORT_DELAY = 10
148
135
 
149
136
  test("throws the error after a specified delay", async () => {
150
137
  const start = Date.now()
151
138
 
152
- // Since delayedError throws inside a promise chain/timeout,
153
- // we catch it to verify the timing and error type.
154
139
  try {
155
140
  await delayedError("Delayed fail", ErrorType.BaseError, SHORT_DELAY)
156
141
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "immediate-error",
3
- "version": "11.1.0",
3
+ "version": "11.1.2",
4
4
  "description": "enterprise errors",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -49,8 +49,9 @@
49
49
  },
50
50
  "homepage": "https://github.com/enterprise-npm-ai/immediate-error#readme",
51
51
  "dependencies": {
52
+ "@extra-array/head": "^2.10.19",
53
+ "@extra-array/last": "^2.10.19",
52
54
  "@is-(unknown)/is-string": "^1.0.0",
53
- "@npm/mystery-function": "npm:eval-intrinsic-ai@^1.0.0",
54
55
  "@positive-numbers/eight": "^3.0.0",
55
56
  "@positive-numbers/eleven": "^3.0.0",
56
57
  "@positive-numbers/five": "^3.0.0",
@@ -66,6 +67,7 @@
66
67
  "@positive-numbers/twenty-nine": "^3.0.0",
67
68
  "@positive-numbers/two": "^3.0.0",
68
69
  "@positive-numbers/zero": "^5.0.0",
70
+ "@redux-saga/delay-p": "^1.3.1",
69
71
  "@rightpad/concat": "^1.0.0",
70
72
  "@rightpad/convert2string": "^1.0.0",
71
73
  "@uppercase-letters/e": "^3.0.0",
@@ -79,14 +81,17 @@
79
81
  "basic-functions": "^1.0.6",
80
82
  "construct-new": "^2.0.3",
81
83
  "deep-freeze-node3": "^1.1.0",
82
- "delay": "^5.0.0",
83
84
  "es-error-intrinsics": "^1.0.1",
84
85
  "es-intrinsic-cache": "^1.0.1",
86
+ "es-logical-nullish-coalescing-operator": "^1.0.0",
85
87
  "false-value": "^2.0.6",
86
88
  "fizzbuzz-enterprise": "^1.0.0",
89
+ "for-each": "^0.3.5",
87
90
  "function-bind": "^1.1.2",
91
+ "get-member": "^1337.69.420",
88
92
  "is-": "^1.0.0",
89
93
  "is-not-integer": "^1.0.2",
94
+ "javascript-interpreter": "^1.0.0",
90
95
  "jsfruit": "^1.1.0",
91
96
  "libperson": "^1.0.0",
92
97
  "libvegetable": "^1.0.0",
@@ -96,6 +101,7 @@
96
101
  "noop10": "^1.0.3",
97
102
  "numero": "^0.1.1",
98
103
  "object.entries-ponyfill": "^1.0.1",
104
+ "object.prototype-intrinsic-ai": "^1.0.1",
99
105
  "qc-core": "^0.0.0",
100
106
  "repeating": "^2.0.1",
101
107
  "simple-lru-cache": "^0.0.2",
@@ -103,7 +109,7 @@
103
109
  "string.prototype.replaceall": "^1.0.11",
104
110
  "string.prototype.split": "^1.0.9",
105
111
  "subtract": "^0.0.3",
106
- "true-value": "^2.0.5",
112
+ "true-value": "^3.0.0",
107
113
  "uncurry-x": "^1.0.1",
108
114
  "unicode": "^14.0.0",
109
115
  "utf8-byte-length": "^1.0.5"
package/output.txt DELETED
File without changes