@xylabs/assert 4.13.19 → 4.13.21
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/README.md +351 -3
- package/package.json +9 -3
- package/xy.config.ts +0 -10
package/README.md
CHANGED
|
@@ -12,13 +12,361 @@
|
|
|
12
12
|
[![snyk-badge][]][snyk-link]
|
|
13
13
|
[![socket-badge][]][socket-link]
|
|
14
14
|
|
|
15
|
-
Version: 4.13.15
|
|
16
15
|
|
|
17
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
18
17
|
|
|
19
|
-
## Documentation
|
|
18
|
+
## API Documentation
|
|
19
|
+
|
|
20
|
+
**@xylabs/assert**
|
|
21
|
+
|
|
22
|
+
***
|
|
23
|
+
|
|
24
|
+
## Type Aliases
|
|
25
|
+
|
|
26
|
+
- [AssertExMessageFunc](#type-aliases/AssertExMessageFunc)
|
|
27
|
+
- [AssertExErrorFunc](#type-aliases/AssertExErrorFunc)
|
|
28
|
+
|
|
29
|
+
## Functions
|
|
30
|
+
|
|
31
|
+
- [assertDefinedEx](#functions/assertDefinedEx)
|
|
32
|
+
- [assertEx](#functions/assertEx)
|
|
33
|
+
|
|
34
|
+
### functions
|
|
35
|
+
|
|
36
|
+
### <a id="assertDefinedEx"></a>assertDefinedEx
|
|
37
|
+
|
|
38
|
+
[**@xylabs/assert**](#../README)
|
|
39
|
+
|
|
40
|
+
***
|
|
41
|
+
|
|
42
|
+
## Call Signature
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
function assertDefinedEx<T>(expr, messageFunc?): T;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Intended for defined checks for variables
|
|
49
|
+
|
|
50
|
+
### Type Parameters
|
|
51
|
+
|
|
52
|
+
### T
|
|
53
|
+
|
|
54
|
+
`T`
|
|
55
|
+
|
|
56
|
+
### Parameters
|
|
57
|
+
|
|
58
|
+
### expr
|
|
59
|
+
|
|
60
|
+
Expression to be evaluated for truthiness
|
|
61
|
+
|
|
62
|
+
`undefined` | `T`
|
|
63
|
+
|
|
64
|
+
### messageFunc?
|
|
65
|
+
|
|
66
|
+
[`AssertExMessageFunc`](#../type-aliases/AssertExMessageFunc)\<`T`\>
|
|
67
|
+
|
|
68
|
+
### Returns
|
|
69
|
+
|
|
70
|
+
`T`
|
|
71
|
+
|
|
72
|
+
Value of expression
|
|
73
|
+
|
|
74
|
+
### Throws
|
|
75
|
+
|
|
76
|
+
AssertExError
|
|
77
|
+
|
|
78
|
+
## Call Signature
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
function assertDefinedEx<T, R>(expr, errorFunc?): T;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Intended for defined checks for variables
|
|
85
|
+
|
|
86
|
+
### Type Parameters
|
|
87
|
+
|
|
88
|
+
### T
|
|
89
|
+
|
|
90
|
+
`T`
|
|
91
|
+
|
|
92
|
+
### R
|
|
93
|
+
|
|
94
|
+
`R` *extends* `Error`
|
|
95
|
+
|
|
96
|
+
### Parameters
|
|
97
|
+
|
|
98
|
+
### expr
|
|
99
|
+
|
|
100
|
+
Expression to be evaluated for truthiness
|
|
101
|
+
|
|
102
|
+
`undefined` | `T`
|
|
103
|
+
|
|
104
|
+
### errorFunc?
|
|
105
|
+
|
|
106
|
+
[`AssertExErrorFunc`](#../type-aliases/AssertExErrorFunc)\<`T`, `R`\>
|
|
107
|
+
|
|
108
|
+
### Returns
|
|
109
|
+
|
|
110
|
+
`T`
|
|
111
|
+
|
|
112
|
+
Value of expression
|
|
113
|
+
|
|
114
|
+
### Throws
|
|
115
|
+
|
|
116
|
+
AssertExError
|
|
117
|
+
|
|
118
|
+
## Call Signature
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
function assertDefinedEx<T>(expr): T;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Type Parameters
|
|
125
|
+
|
|
126
|
+
### T
|
|
127
|
+
|
|
128
|
+
`T`
|
|
129
|
+
|
|
130
|
+
### Parameters
|
|
131
|
+
|
|
132
|
+
### expr
|
|
133
|
+
|
|
134
|
+
`undefined` | `T`
|
|
135
|
+
|
|
136
|
+
### Returns
|
|
137
|
+
|
|
138
|
+
`T`
|
|
139
|
+
|
|
140
|
+
### Deprecated
|
|
141
|
+
|
|
142
|
+
- passing a message will soon be required
|
|
143
|
+
|
|
144
|
+
## Call Signature
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
function assertDefinedEx<T>(expr, message?): T;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Type Parameters
|
|
151
|
+
|
|
152
|
+
### T
|
|
153
|
+
|
|
154
|
+
`T`
|
|
155
|
+
|
|
156
|
+
### Parameters
|
|
157
|
+
|
|
158
|
+
### expr
|
|
159
|
+
|
|
160
|
+
`undefined` | `T`
|
|
161
|
+
|
|
162
|
+
### message?
|
|
163
|
+
|
|
164
|
+
`string`
|
|
165
|
+
|
|
166
|
+
### Returns
|
|
167
|
+
|
|
168
|
+
`T`
|
|
169
|
+
|
|
170
|
+
### Deprecated
|
|
171
|
+
|
|
172
|
+
- replace string with () => string
|
|
173
|
+
|
|
174
|
+
### <a id="assertEx"></a>assertEx
|
|
175
|
+
|
|
176
|
+
[**@xylabs/assert**](#../README)
|
|
177
|
+
|
|
178
|
+
***
|
|
179
|
+
|
|
180
|
+
## Call Signature
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
function assertEx<T>(expr, messageFunc?): T;
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Intended for simple truthiness checks for variables
|
|
187
|
+
|
|
188
|
+
### Type Parameters
|
|
189
|
+
|
|
190
|
+
### T
|
|
191
|
+
|
|
192
|
+
`T`
|
|
193
|
+
|
|
194
|
+
### Parameters
|
|
195
|
+
|
|
196
|
+
### expr
|
|
197
|
+
|
|
198
|
+
Expression to be evaluated for truthiness
|
|
199
|
+
|
|
200
|
+
`undefined` | `null` | `T`
|
|
201
|
+
|
|
202
|
+
### messageFunc?
|
|
203
|
+
|
|
204
|
+
[`AssertExMessageFunc`](#../type-aliases/AssertExMessageFunc)\<`T`\>
|
|
205
|
+
|
|
206
|
+
### Returns
|
|
207
|
+
|
|
208
|
+
`T`
|
|
209
|
+
|
|
210
|
+
Value of expression
|
|
211
|
+
|
|
212
|
+
### Throws
|
|
213
|
+
|
|
214
|
+
AssertExError
|
|
215
|
+
|
|
216
|
+
## Call Signature
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
function assertEx<T, R>(expr, errorFunc?): T;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Intended for simple truthiness checks for variables
|
|
223
|
+
|
|
224
|
+
### Type Parameters
|
|
225
|
+
|
|
226
|
+
### T
|
|
227
|
+
|
|
228
|
+
`T`
|
|
229
|
+
|
|
230
|
+
### R
|
|
231
|
+
|
|
232
|
+
`R` *extends* `Error`
|
|
233
|
+
|
|
234
|
+
### Parameters
|
|
235
|
+
|
|
236
|
+
### expr
|
|
237
|
+
|
|
238
|
+
Expression to be evaluated for truthiness
|
|
239
|
+
|
|
240
|
+
`undefined` | `null` | `T`
|
|
241
|
+
|
|
242
|
+
### errorFunc?
|
|
243
|
+
|
|
244
|
+
[`AssertExErrorFunc`](#../type-aliases/AssertExErrorFunc)\<`T`, `R`\>
|
|
245
|
+
|
|
246
|
+
### Returns
|
|
247
|
+
|
|
248
|
+
`T`
|
|
249
|
+
|
|
250
|
+
Value of expression
|
|
251
|
+
|
|
252
|
+
### Throws
|
|
253
|
+
|
|
254
|
+
AssertExError
|
|
255
|
+
|
|
256
|
+
## Call Signature
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
function assertEx<T>(expr): T;
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Type Parameters
|
|
263
|
+
|
|
264
|
+
### T
|
|
265
|
+
|
|
266
|
+
`T`
|
|
267
|
+
|
|
268
|
+
### Parameters
|
|
269
|
+
|
|
270
|
+
### expr
|
|
271
|
+
|
|
272
|
+
`undefined` | `null` | `T`
|
|
273
|
+
|
|
274
|
+
### Returns
|
|
275
|
+
|
|
276
|
+
`T`
|
|
277
|
+
|
|
278
|
+
### Deprecated
|
|
279
|
+
|
|
280
|
+
- passing a message will soon be required
|
|
281
|
+
|
|
282
|
+
## Call Signature
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
function assertEx<T>(expr, message?): T;
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Type Parameters
|
|
289
|
+
|
|
290
|
+
### T
|
|
291
|
+
|
|
292
|
+
`T`
|
|
293
|
+
|
|
294
|
+
### Parameters
|
|
295
|
+
|
|
296
|
+
### expr
|
|
297
|
+
|
|
298
|
+
`undefined` | `null` | `T`
|
|
299
|
+
|
|
300
|
+
### message?
|
|
301
|
+
|
|
302
|
+
`string`
|
|
303
|
+
|
|
304
|
+
### Returns
|
|
305
|
+
|
|
306
|
+
`T`
|
|
307
|
+
|
|
308
|
+
### Deprecated
|
|
309
|
+
|
|
310
|
+
- replace string with () => string
|
|
311
|
+
|
|
312
|
+
### type-aliases
|
|
313
|
+
|
|
314
|
+
### <a id="AssertExErrorFunc"></a>AssertExErrorFunc
|
|
315
|
+
|
|
316
|
+
[**@xylabs/assert**](#../README)
|
|
317
|
+
|
|
318
|
+
***
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
type AssertExErrorFunc<T, R> = (value?) => R;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Type Parameters
|
|
325
|
+
|
|
326
|
+
### T
|
|
327
|
+
|
|
328
|
+
`T`
|
|
329
|
+
|
|
330
|
+
### R
|
|
331
|
+
|
|
332
|
+
`R` *extends* `Error`
|
|
333
|
+
|
|
334
|
+
## Parameters
|
|
335
|
+
|
|
336
|
+
### value?
|
|
337
|
+
|
|
338
|
+
`T` | `null`
|
|
339
|
+
|
|
340
|
+
## Returns
|
|
341
|
+
|
|
342
|
+
`R`
|
|
343
|
+
|
|
344
|
+
### <a id="AssertExMessageFunc"></a>AssertExMessageFunc
|
|
345
|
+
|
|
346
|
+
[**@xylabs/assert**](#../README)
|
|
347
|
+
|
|
348
|
+
***
|
|
349
|
+
|
|
350
|
+
```ts
|
|
351
|
+
type AssertExMessageFunc<T> = (value?) => string;
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Type Parameters
|
|
355
|
+
|
|
356
|
+
### T
|
|
357
|
+
|
|
358
|
+
`T`
|
|
359
|
+
|
|
360
|
+
## Parameters
|
|
361
|
+
|
|
362
|
+
### value?
|
|
363
|
+
|
|
364
|
+
`T` | `null`
|
|
365
|
+
|
|
366
|
+
## Returns
|
|
367
|
+
|
|
368
|
+
`string`
|
|
20
369
|
|
|
21
|
-
Coming Soon!
|
|
22
370
|
|
|
23
371
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
24
372
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/assert",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.21",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -28,15 +28,21 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/neutral/index.d.ts",
|
|
31
|
+
"source": "./src/index.ts",
|
|
31
32
|
"default": "./dist/neutral/index.mjs"
|
|
32
33
|
},
|
|
33
34
|
"./package.json": "./package.json"
|
|
34
35
|
},
|
|
35
36
|
"module": "./dist/neutral/index.mjs",
|
|
37
|
+
"source": "./src/index.ts",
|
|
36
38
|
"types": "./dist/neutral/index.d.ts",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"src"
|
|
42
|
+
],
|
|
37
43
|
"devDependencies": {
|
|
38
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0
|
|
39
|
-
"@xylabs/tsconfig": "^7.0.0
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0",
|
|
45
|
+
"@xylabs/tsconfig": "^7.0.0",
|
|
40
46
|
"typescript": "^5.8.3"
|
|
41
47
|
},
|
|
42
48
|
"engines": {
|