@xylabs/assert 2.9.2 → 2.10.0

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/docs.json DELETED
@@ -1,687 +0,0 @@
1
- {
2
- "id": 0,
3
- "name": "@xylabs/assert",
4
- "variant": "project",
5
- "kind": 1,
6
- "flags": {},
7
- "children": [
8
- {
9
- "id": 26,
10
- "name": "default",
11
- "variant": "reference",
12
- "kind": 8388608,
13
- "flags": {},
14
- "sources": [
15
- {
16
- "fileName": "index.ts",
17
- "line": 27,
18
- "character": 0,
19
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L27"
20
- }
21
- ],
22
- "target": 12
23
- },
24
- {
25
- "id": 6,
26
- "name": "AssertExErrorFunc",
27
- "variant": "declaration",
28
- "kind": 4194304,
29
- "flags": {},
30
- "sources": [
31
- {
32
- "fileName": "index.ts",
33
- "line": 2,
34
- "character": 12,
35
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L2"
36
- }
37
- ],
38
- "typeParameters": [
39
- {
40
- "id": 10,
41
- "name": "T",
42
- "variant": "typeParam",
43
- "kind": 131072,
44
- "flags": {}
45
- },
46
- {
47
- "id": 11,
48
- "name": "R",
49
- "variant": "typeParam",
50
- "kind": 131072,
51
- "flags": {},
52
- "type": {
53
- "type": "reference",
54
- "target": {
55
- "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts",
56
- "qualifiedName": "Error"
57
- },
58
- "name": "Error",
59
- "package": "typescript"
60
- }
61
- }
62
- ],
63
- "type": {
64
- "type": "reflection",
65
- "declaration": {
66
- "id": 7,
67
- "name": "__type",
68
- "variant": "declaration",
69
- "kind": 65536,
70
- "flags": {},
71
- "sources": [
72
- {
73
- "fileName": "index.ts",
74
- "line": 2,
75
- "character": 52,
76
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L2"
77
- }
78
- ],
79
- "signatures": [
80
- {
81
- "id": 8,
82
- "name": "__type",
83
- "variant": "signature",
84
- "kind": 4096,
85
- "flags": {},
86
- "parameters": [
87
- {
88
- "id": 9,
89
- "name": "value",
90
- "variant": "param",
91
- "kind": 32768,
92
- "flags": {
93
- "isOptional": true
94
- },
95
- "type": {
96
- "type": "union",
97
- "types": [
98
- {
99
- "type": "reference",
100
- "target": -1,
101
- "name": "T",
102
- "refersToTypeParameter": true
103
- },
104
- {
105
- "type": "literal",
106
- "value": null
107
- }
108
- ]
109
- }
110
- }
111
- ],
112
- "type": {
113
- "type": "reference",
114
- "target": -1,
115
- "name": "R",
116
- "refersToTypeParameter": true
117
- }
118
- }
119
- ]
120
- }
121
- }
122
- },
123
- {
124
- "id": 1,
125
- "name": "AssertExMessageFunc",
126
- "variant": "declaration",
127
- "kind": 4194304,
128
- "flags": {},
129
- "sources": [
130
- {
131
- "fileName": "index.ts",
132
- "line": 1,
133
- "character": 12,
134
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L1"
135
- }
136
- ],
137
- "typeParameters": [
138
- {
139
- "id": 5,
140
- "name": "T",
141
- "variant": "typeParam",
142
- "kind": 131072,
143
- "flags": {}
144
- }
145
- ],
146
- "type": {
147
- "type": "reflection",
148
- "declaration": {
149
- "id": 2,
150
- "name": "__type",
151
- "variant": "declaration",
152
- "kind": 65536,
153
- "flags": {},
154
- "sources": [
155
- {
156
- "fileName": "index.ts",
157
- "line": 1,
158
- "character": 37,
159
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L1"
160
- }
161
- ],
162
- "signatures": [
163
- {
164
- "id": 3,
165
- "name": "__type",
166
- "variant": "signature",
167
- "kind": 4096,
168
- "flags": {},
169
- "parameters": [
170
- {
171
- "id": 4,
172
- "name": "value",
173
- "variant": "param",
174
- "kind": 32768,
175
- "flags": {
176
- "isOptional": true
177
- },
178
- "type": {
179
- "type": "union",
180
- "types": [
181
- {
182
- "type": "reference",
183
- "target": -1,
184
- "name": "T",
185
- "refersToTypeParameter": true
186
- },
187
- {
188
- "type": "literal",
189
- "value": null
190
- }
191
- ]
192
- }
193
- }
194
- ],
195
- "type": {
196
- "type": "intrinsic",
197
- "name": "string"
198
- }
199
- }
200
- ]
201
- }
202
- }
203
- },
204
- {
205
- "id": 12,
206
- "name": "assertEx",
207
- "variant": "declaration",
208
- "kind": 64,
209
- "flags": {},
210
- "sources": [
211
- {
212
- "fileName": "index.ts",
213
- "line": 13,
214
- "character": 9,
215
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L13"
216
- },
217
- {
218
- "fileName": "index.ts",
219
- "line": 14,
220
- "character": 9,
221
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L14"
222
- },
223
- {
224
- "fileName": "index.ts",
225
- "line": 15,
226
- "character": 9,
227
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L15"
228
- },
229
- {
230
- "fileName": "index.ts",
231
- "line": 16,
232
- "character": 9,
233
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L16"
234
- }
235
- ],
236
- "signatures": [
237
- {
238
- "id": 13,
239
- "name": "assertEx",
240
- "variant": "signature",
241
- "kind": 4096,
242
- "flags": {},
243
- "comment": {
244
- "summary": [
245
- {
246
- "kind": "text",
247
- "text": "Intended for simple null/undefined checks for variables"
248
- }
249
- ],
250
- "blockTags": [
251
- {
252
- "tag": "@throws",
253
- "content": [
254
- {
255
- "kind": "text",
256
- "text": "AssertExError"
257
- }
258
- ]
259
- },
260
- {
261
- "tag": "@returns",
262
- "content": [
263
- {
264
- "kind": "text",
265
- "text": "Value of expression"
266
- }
267
- ]
268
- }
269
- ]
270
- },
271
- "sources": [
272
- {
273
- "fileName": "index.ts",
274
- "line": 13,
275
- "character": 0,
276
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L13"
277
- }
278
- ],
279
- "typeParameter": [
280
- {
281
- "id": 14,
282
- "name": "T",
283
- "variant": "typeParam",
284
- "kind": 131072,
285
- "flags": {}
286
- }
287
- ],
288
- "parameters": [
289
- {
290
- "id": 15,
291
- "name": "expr",
292
- "variant": "param",
293
- "kind": 32768,
294
- "flags": {
295
- "isOptional": true
296
- },
297
- "comment": {
298
- "summary": [
299
- {
300
- "kind": "text",
301
- "text": "Expression to be evaluated for truthiness"
302
- }
303
- ]
304
- },
305
- "type": {
306
- "type": "union",
307
- "types": [
308
- {
309
- "type": "literal",
310
- "value": null
311
- },
312
- {
313
- "type": "reference",
314
- "target": -1,
315
- "name": "T",
316
- "refersToTypeParameter": true
317
- }
318
- ]
319
- }
320
- },
321
- {
322
- "id": 16,
323
- "name": "message",
324
- "variant": "param",
325
- "kind": 32768,
326
- "flags": {
327
- "isOptional": true
328
- },
329
- "comment": {
330
- "summary": [
331
- {
332
- "kind": "text",
333
- "text": "Message in Error if expression is false, may be a function that returns a string"
334
- }
335
- ]
336
- },
337
- "type": {
338
- "type": "intrinsic",
339
- "name": "string"
340
- }
341
- }
342
- ],
343
- "type": {
344
- "type": "reference",
345
- "target": -1,
346
- "name": "T",
347
- "refersToTypeParameter": true
348
- }
349
- },
350
- {
351
- "id": 17,
352
- "name": "assertEx",
353
- "variant": "signature",
354
- "kind": 4096,
355
- "flags": {},
356
- "sources": [
357
- {
358
- "fileName": "index.ts",
359
- "line": 14,
360
- "character": 0,
361
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L14"
362
- }
363
- ],
364
- "typeParameter": [
365
- {
366
- "id": 18,
367
- "name": "T",
368
- "variant": "typeParam",
369
- "kind": 131072,
370
- "flags": {}
371
- }
372
- ],
373
- "parameters": [
374
- {
375
- "id": 19,
376
- "name": "expr",
377
- "variant": "param",
378
- "kind": 32768,
379
- "flags": {
380
- "isOptional": true
381
- },
382
- "type": {
383
- "type": "union",
384
- "types": [
385
- {
386
- "type": "literal",
387
- "value": null
388
- },
389
- {
390
- "type": "reference",
391
- "target": -1,
392
- "name": "T",
393
- "refersToTypeParameter": true
394
- }
395
- ]
396
- }
397
- },
398
- {
399
- "id": 20,
400
- "name": "messageFunc",
401
- "variant": "param",
402
- "kind": 32768,
403
- "flags": {
404
- "isOptional": true
405
- },
406
- "type": {
407
- "type": "reference",
408
- "target": 1,
409
- "typeArguments": [
410
- {
411
- "type": "reference",
412
- "target": -1,
413
- "name": "T",
414
- "refersToTypeParameter": true
415
- }
416
- ],
417
- "name": "AssertExMessageFunc",
418
- "package": "@xylabs/assert"
419
- }
420
- }
421
- ],
422
- "type": {
423
- "type": "reference",
424
- "target": -1,
425
- "name": "T",
426
- "refersToTypeParameter": true
427
- }
428
- },
429
- {
430
- "id": 21,
431
- "name": "assertEx",
432
- "variant": "signature",
433
- "kind": 4096,
434
- "flags": {},
435
- "sources": [
436
- {
437
- "fileName": "index.ts",
438
- "line": 15,
439
- "character": 0,
440
- "url": "https://github.com/xylabs/sdk-js/blob/88ada5a/packages/assert/src/index.ts#L15"
441
- }
442
- ],
443
- "typeParameter": [
444
- {
445
- "id": 22,
446
- "name": "T",
447
- "variant": "typeParam",
448
- "kind": 131072,
449
- "flags": {}
450
- },
451
- {
452
- "id": 23,
453
- "name": "R",
454
- "variant": "typeParam",
455
- "kind": 131072,
456
- "flags": {},
457
- "type": {
458
- "type": "reference",
459
- "target": {
460
- "sourceFileName": "../../node_modules/typescript/lib/lib.es5.d.ts",
461
- "qualifiedName": "Error"
462
- },
463
- "name": "Error",
464
- "package": "typescript"
465
- }
466
- }
467
- ],
468
- "parameters": [
469
- {
470
- "id": 24,
471
- "name": "expr",
472
- "variant": "param",
473
- "kind": 32768,
474
- "flags": {
475
- "isOptional": true
476
- },
477
- "type": {
478
- "type": "union",
479
- "types": [
480
- {
481
- "type": "literal",
482
- "value": null
483
- },
484
- {
485
- "type": "reference",
486
- "target": -1,
487
- "name": "T",
488
- "refersToTypeParameter": true
489
- }
490
- ]
491
- }
492
- },
493
- {
494
- "id": 25,
495
- "name": "errorFunc",
496
- "variant": "param",
497
- "kind": 32768,
498
- "flags": {
499
- "isOptional": true
500
- },
501
- "type": {
502
- "type": "reference",
503
- "target": 6,
504
- "typeArguments": [
505
- {
506
- "type": "reference",
507
- "target": -1,
508
- "name": "T",
509
- "refersToTypeParameter": true
510
- },
511
- {
512
- "type": "reference",
513
- "target": -1,
514
- "name": "R",
515
- "refersToTypeParameter": true
516
- }
517
- ],
518
- "name": "AssertExErrorFunc",
519
- "package": "@xylabs/assert"
520
- }
521
- }
522
- ],
523
- "type": {
524
- "type": "reference",
525
- "target": -1,
526
- "name": "T",
527
- "refersToTypeParameter": true
528
- }
529
- }
530
- ]
531
- }
532
- ],
533
- "groups": [
534
- {
535
- "title": "References",
536
- "children": [
537
- 26
538
- ]
539
- },
540
- {
541
- "title": "Type Aliases",
542
- "children": [
543
- 6,
544
- 1
545
- ]
546
- },
547
- {
548
- "title": "Functions",
549
- "children": [
550
- 12
551
- ]
552
- }
553
- ],
554
- "packageName": "@xylabs/assert",
555
- "readme": [
556
- {
557
- "kind": "text",
558
- "text": "[![logo][]](https://xylabs.com)\n\n# @xylabs/sdk-js\n\n[![main-build][]][main-build-link]\n[![beta-build][]][beta-build-link]\n[![npm-badge][]][npm-link]\n[![bch-badge][]][bch-link]\n[![codacy-badge][]][codacy-link]\n[![codeclimate-badge][]][codeclimate-link]\n[![snyk-badge][]][snyk-link]\n\n## Table of Contents\n\n- [Description](#description)\n- [Install](#install)\n- [Scripts](#scripts)\n- [Maintainers](#maintainers)\n- [License](#license)\n- [Credits](#credits)\n\n## Description\n\nSDK for base code for Typescript and Javascript Libraries.\n\n## Install\n\nUsing npm:\n\n"
559
- },
560
- {
561
- "kind": "code",
562
- "text": "```sh\nnpm i --save @xylabs/sdk-js\n```"
563
- },
564
- {
565
- "kind": "text",
566
- "text": "\n\nUsing yarn:\n\n"
567
- },
568
- {
569
- "kind": "code",
570
- "text": "```sh\nyarn add @xylabs/sdk-js\n```"
571
- },
572
- {
573
- "kind": "text",
574
- "text": "\n\n## Scripts\n\nSee [ts-scripts](https://github.com/xylabs/ts-scripts/blob/main/README.md)\nfor list of shared scripts.\n\n## Maintainers\n\n- [Arie Trouw](https://github.com/arietrouw) (<https://arietrouw.com>)\n\n## License\n\nSee the [LICENSE](LICENSE) file for license details\n\n## Credits\n\n[Made with 🔥 and ❄️ by XY Labs](https://xylabs.com)\n\n[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg\n[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build-main.yml/badge.svg\n[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build-main.yml\n[beta-build]: https://github.com/xylabs/sdk-js/actions/workflows/build-beta.yml/badge.svg\n[beta-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build-beta.yml\n[npm-badge]: https://img.shields.io/npm/v/@xylabs/sdk-js.svg\n[npm-link]: https://www.npmjs.com/package/@xylabs/sdk-js\n[bch-badge]: https://bettercodehub.com/edge/badge/xylabs/sdk-js?branch=main\n[bch-link]: https://bettercodehub.com/results/xylabs/sdk-js\n[codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698\n[codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade\n[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability\n[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability\n[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json\n[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json"
575
- }
576
- ],
577
- "symbolIdMap": {
578
- "0": {
579
- "sourceFileName": "src/index.ts",
580
- "qualifiedName": ""
581
- },
582
- "1": {
583
- "sourceFileName": "src/index.ts",
584
- "qualifiedName": "AssertExMessageFunc"
585
- },
586
- "2": {
587
- "sourceFileName": "src/index.ts",
588
- "qualifiedName": "__type"
589
- },
590
- "3": {
591
- "sourceFileName": "src/index.ts",
592
- "qualifiedName": "__type"
593
- },
594
- "4": {
595
- "sourceFileName": "src/index.ts",
596
- "qualifiedName": "value"
597
- },
598
- "5": {
599
- "sourceFileName": "src/index.ts",
600
- "qualifiedName": "T"
601
- },
602
- "6": {
603
- "sourceFileName": "src/index.ts",
604
- "qualifiedName": "AssertExErrorFunc"
605
- },
606
- "7": {
607
- "sourceFileName": "src/index.ts",
608
- "qualifiedName": "__type"
609
- },
610
- "8": {
611
- "sourceFileName": "src/index.ts",
612
- "qualifiedName": "__type"
613
- },
614
- "9": {
615
- "sourceFileName": "src/index.ts",
616
- "qualifiedName": "value"
617
- },
618
- "10": {
619
- "sourceFileName": "src/index.ts",
620
- "qualifiedName": "T"
621
- },
622
- "11": {
623
- "sourceFileName": "src/index.ts",
624
- "qualifiedName": "R"
625
- },
626
- "12": {
627
- "sourceFileName": "src/index.ts",
628
- "qualifiedName": "assertEx"
629
- },
630
- "13": {
631
- "sourceFileName": "src/index.ts",
632
- "qualifiedName": "assertEx"
633
- },
634
- "14": {
635
- "sourceFileName": "src/index.ts",
636
- "qualifiedName": "T"
637
- },
638
- "15": {
639
- "sourceFileName": "src/index.ts",
640
- "qualifiedName": "expr"
641
- },
642
- "16": {
643
- "sourceFileName": "src/index.ts",
644
- "qualifiedName": "message"
645
- },
646
- "17": {
647
- "sourceFileName": "src/index.ts",
648
- "qualifiedName": "assertEx"
649
- },
650
- "18": {
651
- "sourceFileName": "src/index.ts",
652
- "qualifiedName": "T"
653
- },
654
- "19": {
655
- "sourceFileName": "src/index.ts",
656
- "qualifiedName": "expr"
657
- },
658
- "20": {
659
- "sourceFileName": "src/index.ts",
660
- "qualifiedName": "messageFunc"
661
- },
662
- "21": {
663
- "sourceFileName": "src/index.ts",
664
- "qualifiedName": "assertEx"
665
- },
666
- "22": {
667
- "sourceFileName": "src/index.ts",
668
- "qualifiedName": "T"
669
- },
670
- "23": {
671
- "sourceFileName": "src/index.ts",
672
- "qualifiedName": "R"
673
- },
674
- "24": {
675
- "sourceFileName": "src/index.ts",
676
- "qualifiedName": "expr"
677
- },
678
- "25": {
679
- "sourceFileName": "src/index.ts",
680
- "qualifiedName": "errorFunc"
681
- },
682
- "26": {
683
- "sourceFileName": "src/index.ts",
684
- "qualifiedName": "default"
685
- }
686
- }
687
- }
package/dist/esm/index.js DELETED
@@ -1,14 +0,0 @@
1
- function assertEx(expr, messageOrFunc) {
2
- if (expr)
3
- return expr;
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
- }
11
- // eslint-disable-next-line import/no-default-export
12
- export default assertEx;
13
- export { assertEx };
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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 +0,0 @@
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"}