@xylabs/assert 2.7.4 → 2.7.6

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/dist/cjs/index.js CHANGED
@@ -1,25 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertEx = void 0;
4
- /**
5
- * Error object thrown by assertEx
6
- */
7
- class AssertExError extends Error {
8
- }
9
- /**
10
- *
11
- * Intended for simple null/undefined checks for variables
12
- *
13
- * @param expr - Expression to be evaluated for truthiness
14
- * @param message - Message in Error if expression is false
15
- * @throws AssertExError
16
- * @returns Value of expression
17
- */
18
- const assertEx = (expr, message) => {
4
+ function assertEx(expr, messageOrFunc) {
19
5
  if (expr)
20
6
  return expr;
21
- throw new AssertExError(message);
22
- };
7
+ if (typeof messageOrFunc === 'function') {
8
+ const errorOrMessage = messageOrFunc(expr);
9
+ throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage;
10
+ }
11
+ // a string was sent
12
+ throw Error(messageOrFunc);
13
+ }
23
14
  exports.assertEx = assertEx;
24
15
  // eslint-disable-next-line import/no-default-export
25
16
  exports.default = assertEx;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,aAAc,SAAQ,KAAK;CAAG;AAEpC;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAI,IAAe,EAAE,OAAgB,EAAK,EAAE;IAC3D,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;AAClC,CAAC,CAAA;AAEQ,4BAAQ;AAEjB,oDAAoD;AACpD,kBAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAeA,SAAS,QAAQ,CAA0F,IAAe,EAAE,aAAiB;IAC3I,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;QACvC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1C,MAAM,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAA;KAClF;IACD,oBAAoB;IACpB,MAAM,KAAK,CAAC,aAAa,CAAC,CAAA;AAC5B,CAAC;AAKQ,4BAAQ;AAHjB,oDAAoD;AACpD,kBAAe,QAAQ,CAAA"}
package/dist/docs.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "originalName": "",
8
8
  "children": [
9
9
  {
10
- "id": 6,
10
+ "id": 26,
11
11
  "name": "default",
12
12
  "kind": 8388608,
13
13
  "kindString": "Reference",
@@ -15,30 +15,222 @@
15
15
  "sources": [
16
16
  {
17
17
  "fileName": "index.ts",
18
- "line": 23,
18
+ "line": 27,
19
19
  "character": 0,
20
- "url": "https://github.com/xylabs/sdk-js/blob/77d5e7f/packages/assert/src/index.ts#L23"
20
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L27"
21
+ }
22
+ ],
23
+ "target": 12
24
+ },
25
+ {
26
+ "id": 6,
27
+ "name": "AssertExErrorFunc",
28
+ "kind": 4194304,
29
+ "kindString": "Type alias",
30
+ "flags": {},
31
+ "sources": [
32
+ {
33
+ "fileName": "index.ts",
34
+ "line": 2,
35
+ "character": 12,
36
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L2"
21
37
  }
22
38
  ],
23
- "target": 1
39
+ "typeParameters": [
40
+ {
41
+ "id": 10,
42
+ "name": "T",
43
+ "kind": 131072,
44
+ "kindString": "Type parameter",
45
+ "flags": {}
46
+ },
47
+ {
48
+ "id": 11,
49
+ "name": "R",
50
+ "kind": 131072,
51
+ "kindString": "Type parameter",
52
+ "flags": {},
53
+ "type": {
54
+ "type": "reference",
55
+ "name": "Error",
56
+ "qualifiedName": "Error",
57
+ "package": "typescript"
58
+ }
59
+ }
60
+ ],
61
+ "type": {
62
+ "type": "reflection",
63
+ "declaration": {
64
+ "id": 7,
65
+ "name": "__type",
66
+ "kind": 65536,
67
+ "kindString": "Type literal",
68
+ "flags": {},
69
+ "sources": [
70
+ {
71
+ "fileName": "index.ts",
72
+ "line": 2,
73
+ "character": 52,
74
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L2"
75
+ }
76
+ ],
77
+ "signatures": [
78
+ {
79
+ "id": 8,
80
+ "name": "__type",
81
+ "kind": 4096,
82
+ "kindString": "Call signature",
83
+ "flags": {},
84
+ "parameters": [
85
+ {
86
+ "id": 9,
87
+ "name": "value",
88
+ "kind": 32768,
89
+ "kindString": "Parameter",
90
+ "flags": {
91
+ "isOptional": true
92
+ },
93
+ "type": {
94
+ "type": "union",
95
+ "types": [
96
+ {
97
+ "type": "reference",
98
+ "id": 10,
99
+ "name": "T"
100
+ },
101
+ {
102
+ "type": "literal",
103
+ "value": null
104
+ }
105
+ ]
106
+ }
107
+ }
108
+ ],
109
+ "type": {
110
+ "type": "reference",
111
+ "id": 11,
112
+ "name": "R"
113
+ }
114
+ }
115
+ ]
116
+ }
117
+ }
24
118
  },
25
119
  {
26
120
  "id": 1,
121
+ "name": "AssertExMessageFunc",
122
+ "kind": 4194304,
123
+ "kindString": "Type alias",
124
+ "flags": {},
125
+ "sources": [
126
+ {
127
+ "fileName": "index.ts",
128
+ "line": 1,
129
+ "character": 12,
130
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L1"
131
+ }
132
+ ],
133
+ "typeParameters": [
134
+ {
135
+ "id": 5,
136
+ "name": "T",
137
+ "kind": 131072,
138
+ "kindString": "Type parameter",
139
+ "flags": {}
140
+ }
141
+ ],
142
+ "type": {
143
+ "type": "reflection",
144
+ "declaration": {
145
+ "id": 2,
146
+ "name": "__type",
147
+ "kind": 65536,
148
+ "kindString": "Type literal",
149
+ "flags": {},
150
+ "sources": [
151
+ {
152
+ "fileName": "index.ts",
153
+ "line": 1,
154
+ "character": 37,
155
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L1"
156
+ }
157
+ ],
158
+ "signatures": [
159
+ {
160
+ "id": 3,
161
+ "name": "__type",
162
+ "kind": 4096,
163
+ "kindString": "Call signature",
164
+ "flags": {},
165
+ "parameters": [
166
+ {
167
+ "id": 4,
168
+ "name": "value",
169
+ "kind": 32768,
170
+ "kindString": "Parameter",
171
+ "flags": {
172
+ "isOptional": true
173
+ },
174
+ "type": {
175
+ "type": "union",
176
+ "types": [
177
+ {
178
+ "type": "reference",
179
+ "id": 5,
180
+ "name": "T"
181
+ },
182
+ {
183
+ "type": "literal",
184
+ "value": null
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ ],
190
+ "type": {
191
+ "type": "intrinsic",
192
+ "name": "string"
193
+ }
194
+ }
195
+ ]
196
+ }
197
+ }
198
+ },
199
+ {
200
+ "id": 12,
27
201
  "name": "assertEx",
28
202
  "kind": 64,
29
203
  "kindString": "Function",
30
204
  "flags": {},
31
205
  "sources": [
206
+ {
207
+ "fileName": "index.ts",
208
+ "line": 13,
209
+ "character": 9,
210
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L13"
211
+ },
212
+ {
213
+ "fileName": "index.ts",
214
+ "line": 14,
215
+ "character": 9,
216
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L14"
217
+ },
32
218
  {
33
219
  "fileName": "index.ts",
34
220
  "line": 15,
35
- "character": 6,
36
- "url": "https://github.com/xylabs/sdk-js/blob/77d5e7f/packages/assert/src/index.ts#L15"
221
+ "character": 9,
222
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L15"
223
+ },
224
+ {
225
+ "fileName": "index.ts",
226
+ "line": 16,
227
+ "character": 9,
228
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L16"
37
229
  }
38
230
  ],
39
231
  "signatures": [
40
232
  {
41
- "id": 2,
233
+ "id": 13,
42
234
  "name": "assertEx",
43
235
  "kind": 4096,
44
236
  "kindString": "Call signature",
@@ -73,7 +265,7 @@
73
265
  },
74
266
  "typeParameter": [
75
267
  {
76
- "id": 3,
268
+ "id": 14,
77
269
  "name": "T",
78
270
  "kind": 131072,
79
271
  "kindString": "Type parameter",
@@ -82,7 +274,7 @@
82
274
  ],
83
275
  "parameters": [
84
276
  {
85
- "id": 4,
277
+ "id": 15,
86
278
  "name": "expr",
87
279
  "kind": 32768,
88
280
  "kindString": "Parameter",
@@ -106,14 +298,14 @@
106
298
  },
107
299
  {
108
300
  "type": "reference",
109
- "id": 3,
301
+ "id": 14,
110
302
  "name": "T"
111
303
  }
112
304
  ]
113
305
  }
114
306
  },
115
307
  {
116
- "id": 5,
308
+ "id": 16,
117
309
  "name": "message",
118
310
  "kind": 32768,
119
311
  "kindString": "Parameter",
@@ -124,7 +316,7 @@
124
316
  "summary": [
125
317
  {
126
318
  "kind": "text",
127
- "text": "Message in Error if expression is false"
319
+ "text": "Message in Error if expression is false, may be a function that returns a string"
128
320
  }
129
321
  ]
130
322
  },
@@ -136,7 +328,159 @@
136
328
  ],
137
329
  "type": {
138
330
  "type": "reference",
139
- "id": 3,
331
+ "id": 14,
332
+ "name": "T"
333
+ }
334
+ },
335
+ {
336
+ "id": 17,
337
+ "name": "assertEx",
338
+ "kind": 4096,
339
+ "kindString": "Call signature",
340
+ "flags": {},
341
+ "typeParameter": [
342
+ {
343
+ "id": 18,
344
+ "name": "T",
345
+ "kind": 131072,
346
+ "kindString": "Type parameter",
347
+ "flags": {}
348
+ }
349
+ ],
350
+ "parameters": [
351
+ {
352
+ "id": 19,
353
+ "name": "expr",
354
+ "kind": 32768,
355
+ "kindString": "Parameter",
356
+ "flags": {
357
+ "isOptional": true
358
+ },
359
+ "type": {
360
+ "type": "union",
361
+ "types": [
362
+ {
363
+ "type": "literal",
364
+ "value": null
365
+ },
366
+ {
367
+ "type": "reference",
368
+ "id": 18,
369
+ "name": "T"
370
+ }
371
+ ]
372
+ }
373
+ },
374
+ {
375
+ "id": 20,
376
+ "name": "messageFunc",
377
+ "kind": 32768,
378
+ "kindString": "Parameter",
379
+ "flags": {
380
+ "isOptional": true
381
+ },
382
+ "type": {
383
+ "type": "reference",
384
+ "id": 1,
385
+ "typeArguments": [
386
+ {
387
+ "type": "reference",
388
+ "id": 18,
389
+ "name": "T"
390
+ }
391
+ ],
392
+ "name": "AssertExMessageFunc"
393
+ }
394
+ }
395
+ ],
396
+ "type": {
397
+ "type": "reference",
398
+ "id": 18,
399
+ "name": "T"
400
+ }
401
+ },
402
+ {
403
+ "id": 21,
404
+ "name": "assertEx",
405
+ "kind": 4096,
406
+ "kindString": "Call signature",
407
+ "flags": {},
408
+ "typeParameter": [
409
+ {
410
+ "id": 22,
411
+ "name": "T",
412
+ "kind": 131072,
413
+ "kindString": "Type parameter",
414
+ "flags": {}
415
+ },
416
+ {
417
+ "id": 23,
418
+ "name": "R",
419
+ "kind": 131072,
420
+ "kindString": "Type parameter",
421
+ "flags": {},
422
+ "type": {
423
+ "type": "reference",
424
+ "name": "Error",
425
+ "qualifiedName": "Error",
426
+ "package": "typescript"
427
+ }
428
+ }
429
+ ],
430
+ "parameters": [
431
+ {
432
+ "id": 24,
433
+ "name": "expr",
434
+ "kind": 32768,
435
+ "kindString": "Parameter",
436
+ "flags": {
437
+ "isOptional": true
438
+ },
439
+ "type": {
440
+ "type": "union",
441
+ "types": [
442
+ {
443
+ "type": "literal",
444
+ "value": null
445
+ },
446
+ {
447
+ "type": "reference",
448
+ "id": 22,
449
+ "name": "T"
450
+ }
451
+ ]
452
+ }
453
+ },
454
+ {
455
+ "id": 25,
456
+ "name": "errorFunc",
457
+ "kind": 32768,
458
+ "kindString": "Parameter",
459
+ "flags": {
460
+ "isOptional": true
461
+ },
462
+ "type": {
463
+ "type": "reference",
464
+ "id": 6,
465
+ "typeArguments": [
466
+ {
467
+ "type": "reference",
468
+ "id": 22,
469
+ "name": "T"
470
+ },
471
+ {
472
+ "type": "reference",
473
+ "id": 23,
474
+ "name": "R"
475
+ }
476
+ ],
477
+ "name": "AssertExErrorFunc"
478
+ }
479
+ }
480
+ ],
481
+ "type": {
482
+ "type": "reference",
483
+ "id": 22,
140
484
  "name": "T"
141
485
  }
142
486
  }
@@ -147,22 +491,29 @@
147
491
  {
148
492
  "title": "References",
149
493
  "children": [
150
- 6
494
+ 26
151
495
  ]
152
496
  },
153
497
  {
154
- "title": "Functions",
498
+ "title": "Type Aliases",
155
499
  "children": [
500
+ 6,
156
501
  1
157
502
  ]
503
+ },
504
+ {
505
+ "title": "Functions",
506
+ "children": [
507
+ 12
508
+ ]
158
509
  }
159
510
  ],
160
511
  "sources": [
161
512
  {
162
513
  "fileName": "index.ts",
163
- "line": 4,
514
+ "line": 1,
164
515
  "character": 0,
165
- "url": "https://github.com/xylabs/sdk-js/blob/77d5e7f/packages/assert/src/index.ts#L4"
516
+ "url": "https://github.com/xylabs/sdk-js/blob/8d1441a/packages/assert/src/index.ts#L1"
166
517
  }
167
518
  ]
168
519
  }
package/dist/esm/index.js CHANGED
@@ -1,23 +1,14 @@
1
- /**
2
- * Error object thrown by assertEx
3
- */
4
- class AssertExError extends Error {
5
- }
6
- /**
7
- *
8
- * Intended for simple null/undefined checks for variables
9
- *
10
- * @param expr - Expression to be evaluated for truthiness
11
- * @param message - Message in Error if expression is false
12
- * @throws AssertExError
13
- * @returns Value of expression
14
- */
15
- const assertEx = (expr, message) => {
1
+ function assertEx(expr, messageOrFunc) {
16
2
  if (expr)
17
3
  return expr;
18
- throw new AssertExError(message);
19
- };
20
- export { assertEx };
4
+ if (typeof messageOrFunc === 'function') {
5
+ const errorOrMessage = messageOrFunc(expr);
6
+ throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage;
7
+ }
8
+ // a string was sent
9
+ throw Error(messageOrFunc);
10
+ }
21
11
  // eslint-disable-next-line import/no-default-export
22
12
  export default assertEx;
13
+ export { assertEx };
23
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,aAAc,SAAQ,KAAK;CAAG;AAEpC;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAI,IAAe,EAAE,OAAgB,EAAK,EAAE;IAC3D,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA;AAEnB,oDAAoD;AACpD,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,SAAS,QAAQ,CAA0F,IAAe,EAAE,aAAiB;IAC3I,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;QACvC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1C,MAAM,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAA;KAClF;IACD,oBAAoB;IACpB,MAAM,KAAK,CAAC,aAAa,CAAC,CAAA;AAC5B,CAAC;AAED,oDAAoD;AACpD,eAAe,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -1,13 +1,17 @@
1
+ export type AssertExMessageFunc<T> = (value?: T | null) => string;
2
+ export type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R;
1
3
  /**
2
4
  *
3
5
  * Intended for simple null/undefined checks for variables
4
6
  *
5
7
  * @param expr - Expression to be evaluated for truthiness
6
- * @param message - Message in Error if expression is false
8
+ * @param message - Message in Error if expression is false, may be a function that returns a string
7
9
  * @throws AssertExError
8
10
  * @returns Value of expression
9
11
  */
10
- declare const assertEx: <T>(expr?: T | null | undefined, message?: string) => T;
11
- export { assertEx };
12
+ declare function assertEx<T>(expr?: T | null, message?: string): T;
13
+ declare function assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T;
14
+ declare function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T;
12
15
  export default assertEx;
16
+ export { assertEx };
13
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,6CAAkC,MAAM,MAGrD,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA;AAGnB,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,MAAM,CAAA;AACjE,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,CAAA;AAE3E;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;AAC1D,iBAAS,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC9E,iBAAS,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;AAY9F,eAAe,QAAQ,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,CAAA"}
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "./package.json": "./package.json"
35
35
  },
36
36
  "devDependencies": {
37
- "@xylabs/ts-scripts-yarn3": "^2.15.0"
37
+ "@xylabs/ts-scripts-yarn3": "^2.16.1"
38
38
  },
39
39
  "homepage": "https://xylabs.com",
40
40
  "keywords": [
@@ -51,5 +51,5 @@
51
51
  "url": "https://github.com/xylabs/sdk-js.git"
52
52
  },
53
53
  "sideEffects": false,
54
- "version": "2.7.4"
54
+ "version": "2.7.6"
55
55
  }
package/src/index.ts CHANGED
@@ -1,23 +1,29 @@
1
- /**
2
- * Error object thrown by assertEx
3
- */
4
- class AssertExError extends Error {}
1
+ export type AssertExMessageFunc<T> = (value?: T | null) => string
2
+ export type AssertExErrorFunc<T, R extends Error> = (value?: T | null) => R
5
3
 
6
4
  /**
7
5
  *
8
6
  * Intended for simple null/undefined checks for variables
9
7
  *
10
8
  * @param expr - Expression to be evaluated for truthiness
11
- * @param message - Message in Error if expression is false
9
+ * @param message - Message in Error if expression is false, may be a function that returns a string
12
10
  * @throws AssertExError
13
11
  * @returns Value of expression
14
12
  */
15
- const assertEx = <T>(expr?: T | null, message?: string): T => {
13
+ function assertEx<T>(expr?: T | null, message?: string): T
14
+ function assertEx<T>(expr?: T | null, messageFunc?: AssertExMessageFunc<T>): T
15
+ function assertEx<T, R extends Error>(expr?: T | null, errorFunc?: AssertExErrorFunc<T, R>): T
16
+ function assertEx<T, R extends Error, P extends string | AssertExMessageFunc<T> | AssertExErrorFunc<T, R>>(expr?: T | null, messageOrFunc?: P): T {
16
17
  if (expr) return expr
17
- throw new AssertExError(message)
18
+ if (typeof messageOrFunc === 'function') {
19
+ const errorOrMessage = messageOrFunc(expr)
20
+ throw typeof errorOrMessage === 'string' ? Error(errorOrMessage) : errorOrMessage
21
+ }
22
+ // a string was sent
23
+ throw Error(messageOrFunc)
18
24
  }
19
25
 
20
- export { assertEx }
21
-
22
26
  // eslint-disable-next-line import/no-default-export
23
27
  export default assertEx
28
+
29
+ export { assertEx }