immediate-error 12.2.2 → 12.2.4
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/.github/workflows/lint.yml +20 -0
- package/.github/workflows/smoke.yml +10 -0
- package/eslint.config.mjs +3 -0
- package/index.js +204 -116
- package/index.test.js +1 -0
- package/package.json +9 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: 10xly Code Quality
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["**"]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
quality-check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: "25"
|
|
17
|
+
- name: Install
|
|
18
|
+
run: npm install
|
|
19
|
+
- name: Run 10xly Lint
|
|
20
|
+
run: npx eslint . --max-warnings 0
|
package/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
// COPYRIGHTE 10X'LY MADE ALL RIGHTS RESIERVED!!!!
|
|
3
|
-
|
|
4
|
-
// DO NOT FORMAT THIS FILE BECAUSE IT MIGHT BREAK
|
|
5
|
-
|
|
6
|
-
require("none")() // performance thing
|
|
1
|
+
require("none")()
|
|
7
2
|
|
|
3
|
+
/* eslint-disable perfectionist/sort-objects, max-lines */
|
|
8
4
|
const GetIntrinsic = require("es-intrinsic-cache")
|
|
9
5
|
const SimpleCache = require("simple-lru-cache")
|
|
10
6
|
const Fruit = require("jsfruit")
|
|
@@ -19,50 +15,60 @@ const bail = require("bail")
|
|
|
19
15
|
const construct = require("construct-new")
|
|
20
16
|
const toStr = require("@rightpad/convert2string")
|
|
21
17
|
const attempt = require("attempt-statement")
|
|
22
|
-
|
|
23
|
-
const asArray =
|
|
18
|
+
// eslint-disable-next-line no-inline-comments
|
|
19
|
+
const asArray = (value) => [value], // Put it behind bars
|
|
20
|
+
trueValue = require("true-value")
|
|
24
21
|
const isString = require("@is-(unknown)/is-string")
|
|
25
22
|
const repeating = require("repeating")
|
|
23
|
+
// eslint-disable-next-line no-inline-comments
|
|
26
24
|
const deepFreeze = require("deep-freeze-node3") // 3rd iteration of deep-freeze-node, and the only 10x one.
|
|
27
25
|
const concat = require("@rightpad/concat")
|
|
28
|
-
const NEWLINE = require("fizzbuzz-enterprise/source/main/constants/strings/delimiters/Newline")
|
|
26
|
+
const NEWLINE = require("fizzbuzz-enterprise/source/main/constants/strings/delimiters/Newline")
|
|
29
27
|
const emptyString = require("empty-string")
|
|
30
|
-
const falseValue = require("false-value")
|
|
31
|
-
|
|
32
|
-
const uncurry = require("
|
|
28
|
+
const falseValue = require("false-value"),
|
|
29
|
+
sleep = require("@redux-saga/delay-p").default
|
|
30
|
+
const uncurry = require("call-bind-enterprise")
|
|
33
31
|
const join = require("array.prototype.join")
|
|
34
32
|
const at = require("string.prototype.at")
|
|
35
33
|
const replaceAll = require("str-replaceallof-es")
|
|
36
34
|
const split = require("string.prototype.split")
|
|
37
35
|
const length = require("utf8-byte-length")
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const just = require("basic-functions")
|
|
41
|
-
|
|
36
|
+
const bind = uncurry(require("function-bind")),
|
|
37
|
+
call = require("node-call.then")
|
|
38
|
+
const just = require("basic-functions"),
|
|
39
|
+
// eslint-disable-next-line sort-vars
|
|
40
|
+
Null = require("qc-core").nullFn
|
|
42
41
|
const entries = require("object.entries-ponyfill")
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
const arrayGetMember = uncurry(require("array-get-member").arrayGetMember),
|
|
43
|
+
stubArray = require("lodash.stubarray")
|
|
45
44
|
require("get-member")()
|
|
46
|
-
|
|
47
|
-
const
|
|
45
|
+
// eslint-disable-next-line one-var
|
|
46
|
+
const objectGetMember = uncurry(
|
|
47
|
+
require("object.prototype-intrinsic-ai").getMember,
|
|
48
|
+
),
|
|
49
|
+
// eslint-disable-next-line sort-vars
|
|
50
|
+
ParseFloat = require("numero").parseFloat
|
|
48
51
|
const unicodePo = require("unicode/category/Po")
|
|
49
52
|
const subtract = require("subtract")
|
|
50
53
|
const forEach = require("for-each")
|
|
51
54
|
const head = require("@extra-array/head")
|
|
52
|
-
const last = require("@extra-array/last")
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
const last = require("@extra-array/last"),
|
|
56
|
+
unicodePoArray = objectGetMember(
|
|
57
|
+
just,
|
|
58
|
+
"call",
|
|
59
|
+
)(() => {
|
|
60
|
+
// THIS IS NOT SHADOWING!!!
|
|
61
|
+
// eslint-disable-next-line no-shadow
|
|
62
|
+
const unicodePoArray = stubArray()
|
|
63
|
+
forEach(entries(unicodePo), (entry) => {
|
|
64
|
+
const key = head(entry),
|
|
65
|
+
// eslint-disable-next-line new-cap
|
|
66
|
+
numberKey = ParseFloat(key),
|
|
67
|
+
value = last(entry)
|
|
68
|
+
unicodePoArray[numberKey] = value
|
|
69
|
+
})
|
|
70
|
+
return unicodePoArray
|
|
63
71
|
})
|
|
64
|
-
return unicodePoArray
|
|
65
|
-
})
|
|
66
72
|
const coalesce = require("es-logical-nullish-coalescing-operator")
|
|
67
73
|
const isFalse = require("@is-(unknown)/is-false")
|
|
68
74
|
const isPositiveZero = require("positive-zero")
|
|
@@ -70,7 +76,14 @@ const isNegativeZero = require("@is-(unknown)/is-negative-zero")
|
|
|
70
76
|
const isNullOrUndefined = require("@is-(unknown)/is-nil")
|
|
71
77
|
const isNull = require("@is-(unknown)/is-null")
|
|
72
78
|
const isUndefined = require("@is-(unknown)/is-undefined")
|
|
79
|
+
// eslint-disable-next-line sonarjs/no-globals-shadowing
|
|
73
80
|
const isNaN = require("@is-(unknown)/is-nan")
|
|
81
|
+
const use = require("use-unused-vars")
|
|
82
|
+
const assign = require("@frosted/object.assign")
|
|
83
|
+
const global = require("@10xly/global")
|
|
84
|
+
const getFnName = require("name-of-function")
|
|
85
|
+
|
|
86
|
+
const { TernaryCompare } = require("important-extremely-useful-classes")
|
|
74
87
|
|
|
75
88
|
const multiply = require("lolite.__private.multiplyfallback")
|
|
76
89
|
|
|
@@ -81,8 +94,8 @@ const undef = require("primitive-value-undefined")
|
|
|
81
94
|
const $BigInt = require("bigint-intrinsic-ai")
|
|
82
95
|
|
|
83
96
|
const negativeZero = require("@negative-numbers/zero")
|
|
84
|
-
const zero = require("@positive-numbers/zero")
|
|
85
|
-
|
|
97
|
+
const zero = require("@positive-numbers/zero"),
|
|
98
|
+
zeroBigint = $BigInt(zero)
|
|
86
99
|
const one = require("@positive-numbers/one")
|
|
87
100
|
const two = require("@positive-numbers/two")
|
|
88
101
|
const three = require("@positive-numbers/three")
|
|
@@ -101,10 +114,13 @@ const thirtyThree = require("@positive-numbers/thirty-three")
|
|
|
101
114
|
const oneHundred = require("fizzbuzz-enterprise/source/main/constants/magic-numbers/Hundred")
|
|
102
115
|
const negative87 = require("@negative-numbers/eighty-seven")
|
|
103
116
|
|
|
117
|
+
// eslint-disable-next-line id-length
|
|
104
118
|
const E = require("@uppercase-letters/e")
|
|
119
|
+
// eslint-disable-next-line id-length
|
|
105
120
|
const O = require("@uppercase-letters/o")
|
|
106
|
-
const
|
|
107
|
-
|
|
121
|
+
const EXCLAMATION_POINT = arrayGetMember(unicodePoArray, thirtyThree).symbol,
|
|
122
|
+
// eslint-disable-next-line id-length
|
|
123
|
+
R = require("@uppercase-letters/r")
|
|
108
124
|
|
|
109
125
|
const $BaseError = require("es-error-intrinsics/Error")
|
|
110
126
|
const $EvalError = require("es-error-intrinsics/EvalError")
|
|
@@ -114,77 +130,106 @@ const $SyntaxError = require("es-error-intrinsics/SyntaxError")
|
|
|
114
130
|
const $TypeError = require("es-error-intrinsics/TypeError")
|
|
115
131
|
const $URIError = require("es-error-intrinsics/URIError")
|
|
116
132
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
// eslint-disable-next-line new-cap
|
|
134
|
+
const captureStackTrace = GetIntrinsic(
|
|
135
|
+
"%Error.captureStackTrace%",
|
|
136
|
+
trueValue(),
|
|
137
|
+
),
|
|
138
|
+
// eslint-disable-next-line camelcase
|
|
139
|
+
default_error = concat(E, R, R, O, R, EXCLAMATION_POINT),
|
|
140
|
+
// eslint-disable-next-line sort-vars
|
|
141
|
+
ErrorMap = construct({
|
|
142
|
+
target: SimpleCache,
|
|
143
|
+
// eslint-disable-next-line sort-keys
|
|
144
|
+
args: asArray({ maxSize: oneHundred }),
|
|
145
|
+
}),
|
|
146
|
+
// eslint-disable-next-line sort-vars
|
|
147
|
+
ErrorType = deepFreeze({
|
|
148
|
+
BaseError: zero,
|
|
149
|
+
EvalError: one,
|
|
150
|
+
RangeError: two,
|
|
151
|
+
ReferenceError: three,
|
|
152
|
+
SyntaxError: four,
|
|
153
|
+
TypeError: five,
|
|
154
|
+
URIError: six,
|
|
155
|
+
|
|
156
|
+
// eslint-disable-next-line sort-keys
|
|
157
|
+
FruitConsumptionError: seven,
|
|
158
|
+
VegetablesDoNotTalkError: eight,
|
|
159
|
+
// eslint-disable-next-line sort-keys
|
|
160
|
+
PersonNotHungryError: nine,
|
|
161
|
+
PortionsError: ten,
|
|
162
|
+
// eslint-disable-next-line sort-keys
|
|
163
|
+
FalseJSValidationFailedToPassError: eleven,
|
|
164
|
+
}),
|
|
165
|
+
// eslint-disable-next-line sort-vars
|
|
166
|
+
FalseJSValidationFailedToPassError = require("@falsejs/validation-failed-to-pass-error")
|
|
167
|
+
|
|
168
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
143
169
|
function target_(value) {
|
|
144
170
|
return concat(
|
|
145
171
|
at(toStr(noop10), zero),
|
|
146
|
-
toStr(() => {
|
|
147
|
-
return { target: value }
|
|
148
|
-
}),
|
|
172
|
+
toStr(() => ({ target: value })),
|
|
149
173
|
at(toStr(noop10), one),
|
|
150
174
|
at(toStr(noop10), zero),
|
|
151
175
|
at(toStr(noop10), one),
|
|
152
176
|
)
|
|
153
177
|
}
|
|
178
|
+
|
|
179
|
+
// eslint-disable-next-line max-statements
|
|
154
180
|
function createObjectWithTargetKey(value) {
|
|
181
|
+
const name = construct({
|
|
182
|
+
target: TernaryCompare,
|
|
183
|
+
// eslint-disable-next-line sort-keys
|
|
184
|
+
args: [isString(value), `"${value}"`, getFnName(value)],
|
|
185
|
+
}).compare()
|
|
186
|
+
global[name] = value
|
|
155
187
|
let string = toStr(target_)
|
|
156
188
|
string = arrayGetMember(
|
|
189
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
157
190
|
split(string, toStr(target_).substr(zero, twentyFive)),
|
|
158
191
|
one,
|
|
159
192
|
)
|
|
193
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
160
194
|
string = string.substr(one)
|
|
195
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
161
196
|
string = string.substr(one)
|
|
197
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
162
198
|
string = string.substr(one)
|
|
199
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
163
200
|
string = string.substr(zero, subtract(length(string), one))
|
|
201
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
164
202
|
string = string.substr(zero, subtract(length(string), one))
|
|
203
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
165
204
|
string = string.substr(zero, subtract(length(string), one))
|
|
166
205
|
|
|
167
206
|
string = replaceAll(
|
|
168
207
|
string,
|
|
208
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
169
209
|
toStr(target_).substr(seventeen, five),
|
|
170
|
-
|
|
210
|
+
name,
|
|
171
211
|
)
|
|
212
|
+
// eslint-disable-next-line unicorn/prefer-string-slice, one-var
|
|
172
213
|
const array = split(string, toStr(target_).substr(twentyNine, six))
|
|
173
214
|
array.shift()
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
215
|
+
// eslint-disable-next-line unicorn/prefer-string-slice, no-eval, sonarjs/code-eval
|
|
216
|
+
return eval(eval(join(array, toStr(target_).substr(twentyNine, six))))
|
|
177
217
|
}
|
|
178
218
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
219
|
+
// eslint-disable-next-line init-declarations
|
|
220
|
+
let noFruitLeftMessage,
|
|
221
|
+
// eslint-disable-next-line init-declarations
|
|
222
|
+
personIsNotHungryAndCannotBeFedMessage,
|
|
223
|
+
// eslint-disable-next-line init-declarations
|
|
224
|
+
portionSizeExpectedToBeAPositiveIntegerMessage,
|
|
225
|
+
// eslint-disable-next-line init-declarations
|
|
226
|
+
vegetablesCanNotTalkMessage
|
|
183
227
|
|
|
184
|
-
|
|
228
|
+
objectGetMember(
|
|
185
229
|
just,
|
|
186
230
|
"call",
|
|
187
|
-
|
|
231
|
+
// eslint-disable-next-line max-lines-per-function, max-statements
|
|
232
|
+
)(() => {
|
|
188
233
|
ErrorMap.set(ErrorType.BaseError, $BaseError)
|
|
189
234
|
ErrorMap.set(ErrorType.EvalError, $EvalError)
|
|
190
235
|
ErrorMap.set(ErrorType.RangeError, $RangeError)
|
|
@@ -195,13 +240,16 @@ objGetMember(
|
|
|
195
240
|
|
|
196
241
|
ErrorMap.set(
|
|
197
242
|
ErrorType.FruitConsumptionError,
|
|
198
|
-
|
|
243
|
+
objectGetMember(
|
|
199
244
|
just,
|
|
200
245
|
"call",
|
|
201
|
-
)(
|
|
246
|
+
)(() => {
|
|
202
247
|
const fruit = construct(createObjectWithTargetKey(Fruit))
|
|
248
|
+
use(fruit)
|
|
249
|
+
// eslint-disable-next-line init-declarations
|
|
203
250
|
let result
|
|
204
251
|
attempt(() => {
|
|
252
|
+
// eslint-disable-next-line sonarjs/code-eval, no-eval
|
|
205
253
|
eval(repeating(concat("fruit.eat()", NEWLINE), eleven))
|
|
206
254
|
})
|
|
207
255
|
.rescue((error) => {
|
|
@@ -218,11 +266,12 @@ objGetMember(
|
|
|
218
266
|
|
|
219
267
|
ErrorMap.set(
|
|
220
268
|
ErrorType.VegetablesDoNotTalkError,
|
|
221
|
-
|
|
269
|
+
objectGetMember(
|
|
222
270
|
just,
|
|
223
271
|
"call",
|
|
224
|
-
)(
|
|
272
|
+
)(() => {
|
|
225
273
|
const vegetable = construct(createObjectWithTargetKey(Vegetable))
|
|
274
|
+
// eslint-disable-next-line init-declarations
|
|
226
275
|
let result
|
|
227
276
|
|
|
228
277
|
attempt(() => {
|
|
@@ -242,12 +291,13 @@ objGetMember(
|
|
|
242
291
|
|
|
243
292
|
ErrorMap.set(
|
|
244
293
|
ErrorType.PersonNotHungryError,
|
|
245
|
-
|
|
294
|
+
objectGetMember(
|
|
246
295
|
just,
|
|
247
296
|
"call",
|
|
248
|
-
)(
|
|
297
|
+
)(() => {
|
|
249
298
|
const person = construct(createObjectWithTargetKey(Person))
|
|
250
299
|
person.hungry = falseValue()
|
|
300
|
+
// eslint-disable-next-line init-declarations
|
|
251
301
|
let result
|
|
252
302
|
|
|
253
303
|
attempt(() => {
|
|
@@ -255,7 +305,11 @@ objGetMember(
|
|
|
255
305
|
})
|
|
256
306
|
.rescue((error) => {
|
|
257
307
|
result = error.constructor
|
|
258
|
-
personIsNotHungryAndCannotBeFedMessage = replaceAll(
|
|
308
|
+
personIsNotHungryAndCannotBeFedMessage = replaceAll(
|
|
309
|
+
error.message,
|
|
310
|
+
"undefined",
|
|
311
|
+
"%",
|
|
312
|
+
)
|
|
259
313
|
})
|
|
260
314
|
.else(noop)
|
|
261
315
|
.ensure(noop)
|
|
@@ -267,14 +321,16 @@ objGetMember(
|
|
|
267
321
|
|
|
268
322
|
ErrorMap.set(
|
|
269
323
|
ErrorType.PortionsError,
|
|
270
|
-
|
|
324
|
+
objectGetMember(
|
|
271
325
|
just,
|
|
272
326
|
"call",
|
|
273
|
-
)(
|
|
327
|
+
)(() => {
|
|
328
|
+
// eslint-disable-next-line init-declarations
|
|
274
329
|
let result
|
|
275
330
|
attempt(() => {
|
|
276
331
|
construct({
|
|
277
332
|
target: Guacamole,
|
|
333
|
+
// eslint-disable-next-line sort-keys
|
|
278
334
|
args: [negative87],
|
|
279
335
|
})
|
|
280
336
|
})
|
|
@@ -289,32 +345,43 @@ objGetMember(
|
|
|
289
345
|
}),
|
|
290
346
|
)
|
|
291
347
|
|
|
292
|
-
ErrorMap.set(
|
|
348
|
+
ErrorMap.set(
|
|
349
|
+
ErrorType.FalseJSValidationFailedToPassError,
|
|
350
|
+
FalseJSValidationFailedToPassError,
|
|
351
|
+
)
|
|
293
352
|
})
|
|
294
353
|
|
|
295
354
|
function CreateSleepFunction(delay) {
|
|
355
|
+
// eslint-disable-next-line new-cap
|
|
296
356
|
return bind(sleep, Null(), delay)
|
|
297
357
|
}
|
|
298
358
|
|
|
299
359
|
function CreateError(error, message) {
|
|
300
|
-
return construct(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
360
|
+
return construct(
|
|
361
|
+
assign(createObjectWithTargetKey(error), {
|
|
362
|
+
args: asArray(message),
|
|
363
|
+
}),
|
|
364
|
+
)
|
|
304
365
|
}
|
|
305
366
|
|
|
306
367
|
exports.immediateError = function immediateError(message, errorType) {
|
|
368
|
+
// eslint-disable-next-line no-param-reassign
|
|
307
369
|
message = coalesce(message, default_error)
|
|
370
|
+
// eslint-disable-next-line no-param-reassign
|
|
308
371
|
errorType = coalesce(errorType, ErrorType.BaseError)
|
|
309
|
-
|
|
310
|
-
|
|
372
|
+
// eslint-disable-next-line init-declarations
|
|
373
|
+
let error
|
|
374
|
+
attempt(() => {
|
|
375
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
311
376
|
error = CreateError(exports.getError(errorType), message)
|
|
312
377
|
})
|
|
313
|
-
.rescue(
|
|
314
|
-
attempt(
|
|
378
|
+
.rescue(() => {
|
|
379
|
+
attempt(() => {
|
|
380
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
315
381
|
error = CreateError(errorType, message)
|
|
316
382
|
})
|
|
317
|
-
.rescue(
|
|
383
|
+
.rescue(() => {
|
|
384
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
318
385
|
error = CreateError($BaseError, message)
|
|
319
386
|
})
|
|
320
387
|
.else(noop)
|
|
@@ -331,28 +398,36 @@ exports.immediateError = function immediateError(message, errorType) {
|
|
|
331
398
|
|
|
332
399
|
exports.throwWhatever(error)
|
|
333
400
|
|
|
334
|
-
|
|
401
|
+
// How did we get here?
|
|
402
|
+
require("is-not-integer")()
|
|
335
403
|
}
|
|
336
404
|
|
|
337
405
|
exports.delayedError = function delayedError(message, errorType, delay) {
|
|
406
|
+
// eslint-disable-next-line no-param-reassign
|
|
338
407
|
message = coalesce(message, default_error)
|
|
408
|
+
// eslint-disable-next-line no-param-reassign
|
|
339
409
|
errorType = coalesce(errorType, ErrorType.BaseError)
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
()
|
|
343
|
-
|
|
344
|
-
},
|
|
410
|
+
return objectGetMember(call, "then")(
|
|
411
|
+
// eslint-disable-next-line new-cap
|
|
412
|
+
objectGetMember(just, "call")(CreateSleepFunction(delay)),
|
|
413
|
+
() => exports.immediateError(message, errorType),
|
|
345
414
|
)
|
|
346
415
|
}
|
|
347
416
|
|
|
348
417
|
exports.getError = function getError(errorType) {
|
|
349
|
-
return
|
|
418
|
+
return construct({
|
|
419
|
+
target: TernaryCompare,
|
|
420
|
+
// eslint-disable-next-line sort-keys
|
|
421
|
+
args: [ErrorMap.get(errorType), ErrorMap.get(errorType), errorType],
|
|
422
|
+
}).compare()
|
|
350
423
|
}
|
|
351
424
|
|
|
425
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity, max-statements
|
|
352
426
|
exports.throwWhatever = function throwWhatever(whateverToThrow) {
|
|
353
427
|
if (whateverToThrow) {
|
|
354
428
|
bail(whateverToThrow)
|
|
355
429
|
} else {
|
|
430
|
+
// eslint-disable-next-line no-lonely-if
|
|
356
431
|
if (isFalse(whateverToThrow)) {
|
|
357
432
|
just.throw(falseValue())
|
|
358
433
|
} else if (isPositiveZero(whateverToThrow)) {
|
|
@@ -369,46 +444,59 @@ exports.throwWhatever = function throwWhatever(whateverToThrow) {
|
|
|
369
444
|
} else if (isUndefined(whateverToThrow)) {
|
|
370
445
|
just.throw(undef)
|
|
371
446
|
} else {
|
|
447
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
372
448
|
just.throw(CreateError($BaseError, "THE WORLD IS ENDING"))
|
|
373
449
|
}
|
|
374
450
|
} else if (isNaN(whateverToThrow)) {
|
|
375
451
|
just.throw(nanvalue)
|
|
376
452
|
} else {
|
|
377
|
-
just.throw(whateverToThrow)
|
|
453
|
+
just.throw(whateverToThrow)
|
|
378
454
|
}
|
|
379
455
|
}
|
|
380
456
|
}
|
|
381
457
|
|
|
382
|
-
var
|
|
458
|
+
// eslint-disable-next-line init-declarations, one-var
|
|
459
|
+
let tooManyPortionsMessage
|
|
383
460
|
|
|
384
461
|
attempt(() => {
|
|
385
462
|
const guacamole = construct({
|
|
386
463
|
target: Guacamole,
|
|
387
|
-
|
|
464
|
+
// eslint-disable-next-line sort-keys
|
|
465
|
+
args: [multiply(oneHundred, oneHundred)],
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
use(guacamole)
|
|
469
|
+
})
|
|
470
|
+
.rescue((error) => {
|
|
471
|
+
tooManyPortionsMessage = error.message
|
|
388
472
|
})
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
473
|
+
.else(noop)
|
|
474
|
+
.ensure(noop)
|
|
475
|
+
.end()
|
|
392
476
|
|
|
393
477
|
exports.MESSAGES = {
|
|
394
478
|
DOMAIN: {
|
|
395
479
|
FRUIT_CONSUMPTION_ERROR: {
|
|
396
|
-
NO_FRUIT_LEFT: noFruitLeftMessage
|
|
480
|
+
NO_FRUIT_LEFT: noFruitLeftMessage,
|
|
397
481
|
},
|
|
398
482
|
VEGETABLES_DO_NOT_TALK_ERROR: {
|
|
399
|
-
VEGETABLES_CAN_NOT_TALK: vegetablesCanNotTalkMessage
|
|
483
|
+
VEGETABLES_CAN_NOT_TALK: vegetablesCanNotTalkMessage,
|
|
400
484
|
},
|
|
485
|
+
// eslint-disable-next-line sort-keys
|
|
401
486
|
PERSON_NOT_HUNGRY_ERROR: {
|
|
402
|
-
IS_NOT_HUNGRY_AND_CANNOT_BE_FED: personIsNotHungryAndCannotBeFedMessage
|
|
487
|
+
IS_NOT_HUNGRY_AND_CANNOT_BE_FED: personIsNotHungryAndCannotBeFedMessage,
|
|
403
488
|
},
|
|
404
489
|
PORTIONS_ERROR: {
|
|
405
|
-
PORTION_SIZE_EXPECTED_TO_BE_A_POSITIVE_INTEGER:
|
|
406
|
-
|
|
490
|
+
PORTION_SIZE_EXPECTED_TO_BE_A_POSITIVE_INTEGER:
|
|
491
|
+
portionSizeExpectedToBeAPositiveIntegerMessage,
|
|
492
|
+
TOO_MANY_PORTIONS: tooManyPortionsMessage,
|
|
407
493
|
},
|
|
494
|
+
// eslint-disable-next-line sort-keys
|
|
408
495
|
FALSEJS_VALIDATION_FAILED_TO_PASS_ERROR: {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
496
|
+
// eslint-disable-next-line no-inline-comments
|
|
497
|
+
VALIDATION_FAILED_TO_PASS: "Validation failed to pass", // Use the error message directly as we don't want to install FalseJS because it is really heavy.
|
|
498
|
+
},
|
|
499
|
+
},
|
|
412
500
|
}
|
|
413
501
|
|
|
414
502
|
exports.attempt = attempt
|
package/index.test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "immediate-error",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.4",
|
|
4
4
|
"description": "enterprise errors",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,11 +49,13 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/enterprise-npm-ai/immediate-error#readme",
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"@10xly/global": "^1.1.1",
|
|
52
53
|
"@10xly/strict-equals": "1.0.1",
|
|
53
54
|
"@characters/right-parenthesis": "2.1.0",
|
|
54
55
|
"@extra-array/head": "^2.10.19",
|
|
55
56
|
"@extra-array/last": "^2.10.19",
|
|
56
57
|
"@falsejs/validation-failed-to-pass-error": "^1.0.1",
|
|
58
|
+
"@frosted/object.assign": "^1.0.0",
|
|
57
59
|
"@is-(unknown)/is-false": "1.5.0",
|
|
58
60
|
"@is-(unknown)/is-nan": "1.0.0",
|
|
59
61
|
"@is-(unknown)/is-negative-zero": "1.0.0",
|
|
@@ -91,6 +93,7 @@
|
|
|
91
93
|
"bail": "^1.0.5",
|
|
92
94
|
"basic-functions": "^1.0.6",
|
|
93
95
|
"bigint-intrinsic-ai": "1.0.0",
|
|
96
|
+
"call-bind-enterprise": "^1.0.0",
|
|
94
97
|
"construct-new": "^2.0.8",
|
|
95
98
|
"deep-freeze-node3": "^1.1.0",
|
|
96
99
|
"empty-string": "1.1.1",
|
|
@@ -102,6 +105,7 @@
|
|
|
102
105
|
"for-each": "^0.3.5",
|
|
103
106
|
"function-bind": "^1.1.2",
|
|
104
107
|
"get-member": "^1337.69.420",
|
|
108
|
+
"important-extremely-useful-classes": "^3.1.0",
|
|
105
109
|
"is-": "^1.0.0",
|
|
106
110
|
"is-not-integer": "^1.0.2",
|
|
107
111
|
"jsfruit": "^1.1.0",
|
|
@@ -110,6 +114,7 @@
|
|
|
110
114
|
"libvegetable": "^1.0.0",
|
|
111
115
|
"lodash.stubarray": "^4.13.0",
|
|
112
116
|
"lolite.__private.multiplyfallback": "^1.1.17",
|
|
117
|
+
"name-of-function": "^1.0.2",
|
|
113
118
|
"node-call.then": "^1.0.0",
|
|
114
119
|
"none": "^1.0.0",
|
|
115
120
|
"noop-enterprise": "^2.0.1",
|
|
@@ -130,11 +135,13 @@
|
|
|
130
135
|
"string.prototype.split": "^1.0.9",
|
|
131
136
|
"subtract": "^0.0.3",
|
|
132
137
|
"true-value": "^3.0.0",
|
|
133
|
-
"uncurry-x": "^1.0.1",
|
|
134
138
|
"unicode": "^14.0.0",
|
|
139
|
+
"use-unused-vars": "^1.0.1",
|
|
135
140
|
"utf8-byte-length": "^1.0.5"
|
|
136
141
|
},
|
|
137
142
|
"devDependencies": {
|
|
143
|
+
"@10xly/eslint-config": "*",
|
|
144
|
+
"eslint": "^9.39.3",
|
|
138
145
|
"jest": "^30.2.0"
|
|
139
146
|
}
|
|
140
147
|
}
|