immediate-error 12.2.2 → 12.2.3
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/eslint.config.mjs +3 -0
- package/index.js +194 -111
- package/index.test.js +1 -0
- package/package.json +5 -1
|
@@ -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
|
-
|
|
28
|
+
const falseValue = require("false-value"),
|
|
29
|
+
sleep = require("@redux-saga/delay-p").default
|
|
32
30
|
const uncurry = require("uncurry-x")
|
|
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,11 @@ 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
|
+
|
|
83
|
+
const { TernaryCompare } = require("important-extremely-useful-classes")
|
|
74
84
|
|
|
75
85
|
const multiply = require("lolite.__private.multiplyfallback")
|
|
76
86
|
|
|
@@ -81,8 +91,8 @@ const undef = require("primitive-value-undefined")
|
|
|
81
91
|
const $BigInt = require("bigint-intrinsic-ai")
|
|
82
92
|
|
|
83
93
|
const negativeZero = require("@negative-numbers/zero")
|
|
84
|
-
const zero = require("@positive-numbers/zero")
|
|
85
|
-
|
|
94
|
+
const zero = require("@positive-numbers/zero"),
|
|
95
|
+
zeroBigint = $BigInt(zero)
|
|
86
96
|
const one = require("@positive-numbers/one")
|
|
87
97
|
const two = require("@positive-numbers/two")
|
|
88
98
|
const three = require("@positive-numbers/three")
|
|
@@ -101,10 +111,13 @@ const thirtyThree = require("@positive-numbers/thirty-three")
|
|
|
101
111
|
const oneHundred = require("fizzbuzz-enterprise/source/main/constants/magic-numbers/Hundred")
|
|
102
112
|
const negative87 = require("@negative-numbers/eighty-seven")
|
|
103
113
|
|
|
114
|
+
// eslint-disable-next-line id-length
|
|
104
115
|
const E = require("@uppercase-letters/e")
|
|
116
|
+
// eslint-disable-next-line id-length
|
|
105
117
|
const O = require("@uppercase-letters/o")
|
|
106
|
-
const
|
|
107
|
-
|
|
118
|
+
const EXCLAMATION_POINT = arrayGetMember(unicodePoArray, thirtyThree).symbol,
|
|
119
|
+
// eslint-disable-next-line id-length
|
|
120
|
+
R = require("@uppercase-letters/r")
|
|
108
121
|
|
|
109
122
|
const $BaseError = require("es-error-intrinsics/Error")
|
|
110
123
|
const $EvalError = require("es-error-intrinsics/EvalError")
|
|
@@ -114,77 +127,104 @@ const $SyntaxError = require("es-error-intrinsics/SyntaxError")
|
|
|
114
127
|
const $TypeError = require("es-error-intrinsics/TypeError")
|
|
115
128
|
const $URIError = require("es-error-intrinsics/URIError")
|
|
116
129
|
|
|
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
|
-
|
|
130
|
+
// eslint-disable-next-line new-cap
|
|
131
|
+
const captureStackTrace = GetIntrinsic(
|
|
132
|
+
"%Error.captureStackTrace%",
|
|
133
|
+
trueValue(),
|
|
134
|
+
),
|
|
135
|
+
// eslint-disable-next-line camelcase
|
|
136
|
+
default_error = concat(E, R, R, O, R, EXCLAMATION_POINT),
|
|
137
|
+
// eslint-disable-next-line sort-vars
|
|
138
|
+
ErrorMap = construct({
|
|
139
|
+
target: SimpleCache,
|
|
140
|
+
// eslint-disable-next-line sort-keys
|
|
141
|
+
args: asArray({ maxSize: oneHundred }),
|
|
142
|
+
}),
|
|
143
|
+
// eslint-disable-next-line sort-vars
|
|
144
|
+
ErrorType = deepFreeze({
|
|
145
|
+
BaseError: zero,
|
|
146
|
+
EvalError: one,
|
|
147
|
+
RangeError: two,
|
|
148
|
+
ReferenceError: three,
|
|
149
|
+
SyntaxError: four,
|
|
150
|
+
TypeError: five,
|
|
151
|
+
URIError: six,
|
|
152
|
+
|
|
153
|
+
// eslint-disable-next-line sort-keys
|
|
154
|
+
FruitConsumptionError: seven,
|
|
155
|
+
VegetablesDoNotTalkError: eight,
|
|
156
|
+
// eslint-disable-next-line sort-keys
|
|
157
|
+
PersonNotHungryError: nine,
|
|
158
|
+
PortionsError: ten,
|
|
159
|
+
// eslint-disable-next-line sort-keys
|
|
160
|
+
FalseJSValidationFailedToPassError: eleven,
|
|
161
|
+
}),
|
|
162
|
+
// eslint-disable-next-line sort-vars
|
|
163
|
+
FalseJSValidationFailedToPassError = require("@falsejs/validation-failed-to-pass-error")
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
143
166
|
function target_(value) {
|
|
144
167
|
return concat(
|
|
145
168
|
at(toStr(noop10), zero),
|
|
146
|
-
toStr(() => {
|
|
147
|
-
return { target: value }
|
|
148
|
-
}),
|
|
169
|
+
toStr(() => ({ target: value })),
|
|
149
170
|
at(toStr(noop10), one),
|
|
150
171
|
at(toStr(noop10), zero),
|
|
151
172
|
at(toStr(noop10), one),
|
|
152
173
|
)
|
|
153
174
|
}
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line max-statements
|
|
154
177
|
function createObjectWithTargetKey(value) {
|
|
155
178
|
let string = toStr(target_)
|
|
156
179
|
string = arrayGetMember(
|
|
180
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
157
181
|
split(string, toStr(target_).substr(zero, twentyFive)),
|
|
158
182
|
one,
|
|
159
183
|
)
|
|
184
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
160
185
|
string = string.substr(one)
|
|
186
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
161
187
|
string = string.substr(one)
|
|
188
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
162
189
|
string = string.substr(one)
|
|
190
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
163
191
|
string = string.substr(zero, subtract(length(string), one))
|
|
192
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
164
193
|
string = string.substr(zero, subtract(length(string), one))
|
|
194
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
165
195
|
string = string.substr(zero, subtract(length(string), one))
|
|
166
196
|
|
|
167
197
|
string = replaceAll(
|
|
168
198
|
string,
|
|
199
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
169
200
|
toStr(target_).substr(seventeen, five),
|
|
170
|
-
|
|
201
|
+
construct({
|
|
202
|
+
target: TernaryCompare,
|
|
203
|
+
// eslint-disable-next-line sort-keys
|
|
204
|
+
args: [isString(value), `"${value}"`, value.name]
|
|
205
|
+
}).compare()
|
|
171
206
|
)
|
|
207
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
172
208
|
const array = split(string, toStr(target_).substr(twentyNine, six))
|
|
173
209
|
array.shift()
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
210
|
+
// eslint-disable-next-line unicorn/prefer-string-slice, no-eval, sonarjs/code-eval
|
|
211
|
+
return eval(eval(join(array, toStr(target_).substr(twentyNine, six))))
|
|
177
212
|
}
|
|
178
213
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
214
|
+
// eslint-disable-next-line init-declarations
|
|
215
|
+
let noFruitLeftMessage,
|
|
216
|
+
// eslint-disable-next-line init-declarations
|
|
217
|
+
personIsNotHungryAndCannotBeFedMessage,
|
|
218
|
+
// eslint-disable-next-line init-declarations
|
|
219
|
+
portionSizeExpectedToBeAPositiveIntegerMessage,
|
|
220
|
+
// eslint-disable-next-line init-declarations
|
|
221
|
+
vegetablesCanNotTalkMessage
|
|
183
222
|
|
|
184
|
-
|
|
223
|
+
objectGetMember(
|
|
185
224
|
just,
|
|
186
225
|
"call",
|
|
187
|
-
|
|
226
|
+
// eslint-disable-next-line max-lines-per-function, max-statements
|
|
227
|
+
)(() => {
|
|
188
228
|
ErrorMap.set(ErrorType.BaseError, $BaseError)
|
|
189
229
|
ErrorMap.set(ErrorType.EvalError, $EvalError)
|
|
190
230
|
ErrorMap.set(ErrorType.RangeError, $RangeError)
|
|
@@ -195,13 +235,16 @@ objGetMember(
|
|
|
195
235
|
|
|
196
236
|
ErrorMap.set(
|
|
197
237
|
ErrorType.FruitConsumptionError,
|
|
198
|
-
|
|
238
|
+
objectGetMember(
|
|
199
239
|
just,
|
|
200
240
|
"call",
|
|
201
|
-
)(
|
|
241
|
+
)(() => {
|
|
202
242
|
const fruit = construct(createObjectWithTargetKey(Fruit))
|
|
243
|
+
use(fruit)
|
|
244
|
+
// eslint-disable-next-line init-declarations
|
|
203
245
|
let result
|
|
204
246
|
attempt(() => {
|
|
247
|
+
// eslint-disable-next-line sonarjs/code-eval, no-eval
|
|
205
248
|
eval(repeating(concat("fruit.eat()", NEWLINE), eleven))
|
|
206
249
|
})
|
|
207
250
|
.rescue((error) => {
|
|
@@ -218,11 +261,12 @@ objGetMember(
|
|
|
218
261
|
|
|
219
262
|
ErrorMap.set(
|
|
220
263
|
ErrorType.VegetablesDoNotTalkError,
|
|
221
|
-
|
|
264
|
+
objectGetMember(
|
|
222
265
|
just,
|
|
223
266
|
"call",
|
|
224
|
-
)(
|
|
267
|
+
)(() => {
|
|
225
268
|
const vegetable = construct(createObjectWithTargetKey(Vegetable))
|
|
269
|
+
// eslint-disable-next-line init-declarations
|
|
226
270
|
let result
|
|
227
271
|
|
|
228
272
|
attempt(() => {
|
|
@@ -242,12 +286,13 @@ objGetMember(
|
|
|
242
286
|
|
|
243
287
|
ErrorMap.set(
|
|
244
288
|
ErrorType.PersonNotHungryError,
|
|
245
|
-
|
|
289
|
+
objectGetMember(
|
|
246
290
|
just,
|
|
247
291
|
"call",
|
|
248
|
-
)(
|
|
292
|
+
)(() => {
|
|
249
293
|
const person = construct(createObjectWithTargetKey(Person))
|
|
250
294
|
person.hungry = falseValue()
|
|
295
|
+
// eslint-disable-next-line init-declarations
|
|
251
296
|
let result
|
|
252
297
|
|
|
253
298
|
attempt(() => {
|
|
@@ -255,7 +300,11 @@ objGetMember(
|
|
|
255
300
|
})
|
|
256
301
|
.rescue((error) => {
|
|
257
302
|
result = error.constructor
|
|
258
|
-
personIsNotHungryAndCannotBeFedMessage = replaceAll(
|
|
303
|
+
personIsNotHungryAndCannotBeFedMessage = replaceAll(
|
|
304
|
+
error.message,
|
|
305
|
+
"undefined",
|
|
306
|
+
"%",
|
|
307
|
+
)
|
|
259
308
|
})
|
|
260
309
|
.else(noop)
|
|
261
310
|
.ensure(noop)
|
|
@@ -267,14 +316,16 @@ objGetMember(
|
|
|
267
316
|
|
|
268
317
|
ErrorMap.set(
|
|
269
318
|
ErrorType.PortionsError,
|
|
270
|
-
|
|
319
|
+
objectGetMember(
|
|
271
320
|
just,
|
|
272
321
|
"call",
|
|
273
|
-
)(
|
|
322
|
+
)(() => {
|
|
323
|
+
// eslint-disable-next-line init-declarations
|
|
274
324
|
let result
|
|
275
325
|
attempt(() => {
|
|
276
326
|
construct({
|
|
277
327
|
target: Guacamole,
|
|
328
|
+
// eslint-disable-next-line sort-keys
|
|
278
329
|
args: [negative87],
|
|
279
330
|
})
|
|
280
331
|
})
|
|
@@ -289,32 +340,43 @@ objGetMember(
|
|
|
289
340
|
}),
|
|
290
341
|
)
|
|
291
342
|
|
|
292
|
-
ErrorMap.set(
|
|
343
|
+
ErrorMap.set(
|
|
344
|
+
ErrorType.FalseJSValidationFailedToPassError,
|
|
345
|
+
FalseJSValidationFailedToPassError,
|
|
346
|
+
)
|
|
293
347
|
})
|
|
294
348
|
|
|
295
349
|
function CreateSleepFunction(delay) {
|
|
350
|
+
// eslint-disable-next-line new-cap
|
|
296
351
|
return bind(sleep, Null(), delay)
|
|
297
352
|
}
|
|
298
353
|
|
|
299
354
|
function CreateError(error, message) {
|
|
300
355
|
return construct({
|
|
301
356
|
target: error,
|
|
357
|
+
// eslint-disable-next-line sort-keys
|
|
302
358
|
args: asArray(message),
|
|
303
359
|
})
|
|
304
360
|
}
|
|
305
361
|
|
|
306
362
|
exports.immediateError = function immediateError(message, errorType) {
|
|
363
|
+
// eslint-disable-next-line no-param-reassign
|
|
307
364
|
message = coalesce(message, default_error)
|
|
365
|
+
// eslint-disable-next-line no-param-reassign
|
|
308
366
|
errorType = coalesce(errorType, ErrorType.BaseError)
|
|
309
|
-
|
|
310
|
-
|
|
367
|
+
// eslint-disable-next-line init-declarations
|
|
368
|
+
let error
|
|
369
|
+
attempt(() => {
|
|
370
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
311
371
|
error = CreateError(exports.getError(errorType), message)
|
|
312
372
|
})
|
|
313
|
-
.rescue(
|
|
314
|
-
attempt(
|
|
373
|
+
.rescue(() => {
|
|
374
|
+
attempt(() => {
|
|
375
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
315
376
|
error = CreateError(errorType, message)
|
|
316
377
|
})
|
|
317
|
-
.rescue(
|
|
378
|
+
.rescue(() => {
|
|
379
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
318
380
|
error = CreateError($BaseError, message)
|
|
319
381
|
})
|
|
320
382
|
.else(noop)
|
|
@@ -331,28 +393,36 @@ exports.immediateError = function immediateError(message, errorType) {
|
|
|
331
393
|
|
|
332
394
|
exports.throwWhatever(error)
|
|
333
395
|
|
|
334
|
-
|
|
396
|
+
// How did we get here?
|
|
397
|
+
require("is-not-integer")()
|
|
335
398
|
}
|
|
336
399
|
|
|
337
400
|
exports.delayedError = function delayedError(message, errorType, delay) {
|
|
401
|
+
// eslint-disable-next-line no-param-reassign
|
|
338
402
|
message = coalesce(message, default_error)
|
|
403
|
+
// eslint-disable-next-line no-param-reassign
|
|
339
404
|
errorType = coalesce(errorType, ErrorType.BaseError)
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
()
|
|
343
|
-
|
|
344
|
-
},
|
|
405
|
+
return objectGetMember(call, "then")(
|
|
406
|
+
// eslint-disable-next-line new-cap
|
|
407
|
+
objectGetMember(just, "call")(CreateSleepFunction(delay)),
|
|
408
|
+
() => exports.immediateError(message, errorType),
|
|
345
409
|
)
|
|
346
410
|
}
|
|
347
411
|
|
|
348
412
|
exports.getError = function getError(errorType) {
|
|
349
|
-
return
|
|
413
|
+
return construct({
|
|
414
|
+
target: TernaryCompare,
|
|
415
|
+
// eslint-disable-next-line sort-keys
|
|
416
|
+
args: [ErrorMap.get(errorType), ErrorMap.get(errorType), errorType]
|
|
417
|
+
}).compare()
|
|
350
418
|
}
|
|
351
419
|
|
|
420
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity, max-statements
|
|
352
421
|
exports.throwWhatever = function throwWhatever(whateverToThrow) {
|
|
353
422
|
if (whateverToThrow) {
|
|
354
423
|
bail(whateverToThrow)
|
|
355
424
|
} else {
|
|
425
|
+
// eslint-disable-next-line no-lonely-if
|
|
356
426
|
if (isFalse(whateverToThrow)) {
|
|
357
427
|
just.throw(falseValue())
|
|
358
428
|
} else if (isPositiveZero(whateverToThrow)) {
|
|
@@ -369,46 +439,59 @@ exports.throwWhatever = function throwWhatever(whateverToThrow) {
|
|
|
369
439
|
} else if (isUndefined(whateverToThrow)) {
|
|
370
440
|
just.throw(undef)
|
|
371
441
|
} else {
|
|
442
|
+
// eslint-disable-next-line new-cap, unicorn/throw-new-error
|
|
372
443
|
just.throw(CreateError($BaseError, "THE WORLD IS ENDING"))
|
|
373
444
|
}
|
|
374
445
|
} else if (isNaN(whateverToThrow)) {
|
|
375
446
|
just.throw(nanvalue)
|
|
376
447
|
} else {
|
|
377
|
-
just.throw(whateverToThrow)
|
|
448
|
+
just.throw(whateverToThrow)
|
|
378
449
|
}
|
|
379
450
|
}
|
|
380
451
|
}
|
|
381
452
|
|
|
382
|
-
var
|
|
453
|
+
// eslint-disable-next-line init-declarations, one-var
|
|
454
|
+
let tooManyPortionsMessage
|
|
383
455
|
|
|
384
456
|
attempt(() => {
|
|
385
457
|
const guacamole = construct({
|
|
386
458
|
target: Guacamole,
|
|
387
|
-
|
|
459
|
+
// eslint-disable-next-line sort-keys
|
|
460
|
+
args: [multiply(oneHundred, oneHundred)],
|
|
388
461
|
})
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
})
|
|
462
|
+
|
|
463
|
+
use(guacamole)
|
|
464
|
+
})
|
|
465
|
+
.rescue((error) => {
|
|
466
|
+
tooManyPortionsMessage = error.message
|
|
467
|
+
})
|
|
468
|
+
.else(noop)
|
|
469
|
+
.ensure(noop)
|
|
470
|
+
.end()
|
|
392
471
|
|
|
393
472
|
exports.MESSAGES = {
|
|
394
473
|
DOMAIN: {
|
|
395
474
|
FRUIT_CONSUMPTION_ERROR: {
|
|
396
|
-
NO_FRUIT_LEFT: noFruitLeftMessage
|
|
475
|
+
NO_FRUIT_LEFT: noFruitLeftMessage,
|
|
397
476
|
},
|
|
398
477
|
VEGETABLES_DO_NOT_TALK_ERROR: {
|
|
399
|
-
VEGETABLES_CAN_NOT_TALK: vegetablesCanNotTalkMessage
|
|
478
|
+
VEGETABLES_CAN_NOT_TALK: vegetablesCanNotTalkMessage,
|
|
400
479
|
},
|
|
480
|
+
// eslint-disable-next-line sort-keys
|
|
401
481
|
PERSON_NOT_HUNGRY_ERROR: {
|
|
402
|
-
IS_NOT_HUNGRY_AND_CANNOT_BE_FED: personIsNotHungryAndCannotBeFedMessage
|
|
482
|
+
IS_NOT_HUNGRY_AND_CANNOT_BE_FED: personIsNotHungryAndCannotBeFedMessage,
|
|
403
483
|
},
|
|
404
484
|
PORTIONS_ERROR: {
|
|
405
|
-
PORTION_SIZE_EXPECTED_TO_BE_A_POSITIVE_INTEGER:
|
|
406
|
-
|
|
485
|
+
PORTION_SIZE_EXPECTED_TO_BE_A_POSITIVE_INTEGER:
|
|
486
|
+
portionSizeExpectedToBeAPositiveIntegerMessage,
|
|
487
|
+
TOO_MANY_PORTIONS: tooManyPortionsMessage,
|
|
407
488
|
},
|
|
489
|
+
// eslint-disable-next-line sort-keys
|
|
408
490
|
FALSEJS_VALIDATION_FAILED_TO_PASS_ERROR: {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
491
|
+
// eslint-disable-next-line no-inline-comments
|
|
492
|
+
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.
|
|
493
|
+
},
|
|
494
|
+
},
|
|
412
495
|
}
|
|
413
496
|
|
|
414
497
|
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.3",
|
|
4
4
|
"description": "enterprise errors",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"for-each": "^0.3.5",
|
|
103
103
|
"function-bind": "^1.1.2",
|
|
104
104
|
"get-member": "^1337.69.420",
|
|
105
|
+
"important-extremely-useful-classes": "^3.1.0",
|
|
105
106
|
"is-": "^1.0.0",
|
|
106
107
|
"is-not-integer": "^1.0.2",
|
|
107
108
|
"jsfruit": "^1.1.0",
|
|
@@ -132,9 +133,12 @@
|
|
|
132
133
|
"true-value": "^3.0.0",
|
|
133
134
|
"uncurry-x": "^1.0.1",
|
|
134
135
|
"unicode": "^14.0.0",
|
|
136
|
+
"use-unused-vars": "^1.0.1",
|
|
135
137
|
"utf8-byte-length": "^1.0.5"
|
|
136
138
|
},
|
|
137
139
|
"devDependencies": {
|
|
140
|
+
"@10xly/eslint-config": "*",
|
|
141
|
+
"eslint": "^9.39.3",
|
|
138
142
|
"jest": "^30.2.0"
|
|
139
143
|
}
|
|
140
144
|
}
|