@xylabs/exists 4.13.20 → 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.
Files changed (2) hide show
  1. package/README.md +50 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -12,13 +12,60 @@
12
12
  [![snyk-badge][]][snyk-link]
13
13
  [![socket-badge][]][socket-link]
14
14
 
15
- Version: 4.13.19
16
15
 
17
16
  Base functionality used throughout XY Labs TypeScript/JavaScript libraries
18
17
 
19
- ## Documentation
18
+ ## API Documentation
19
+
20
+ **@xylabs/exists**
21
+
22
+ ***
23
+
24
+ ## Functions
25
+
26
+ - [exists](#functions/exists)
27
+
28
+ ### functions
29
+
30
+ ### <a id="exists"></a>exists
31
+
32
+ [**@xylabs/exists**](#../README)
33
+
34
+ ***
35
+
36
+ ```ts
37
+ function exists<T>(x?): x is NonNullable<T>;
38
+ ```
39
+
40
+ Used to type narrow an object which is possibly null or undefined. Works well
41
+ with functional Array methods. For example:
42
+
43
+ ## Type Parameters
44
+
45
+ ### T
46
+
47
+ `T`
48
+
49
+ ## Parameters
50
+
51
+ ### x?
52
+
53
+ The object which is potentially undefined or null
54
+
55
+ `null` | `T`
56
+
57
+ ## Returns
58
+
59
+ `x is NonNullable<T>`
60
+
61
+ False if the object is null/undefined, true otherwise
62
+
63
+ ## Example
64
+
65
+ ```ts
66
+ const payloads: XyoPayload[] = boundWitness._payloads?.filter(exists) || []
67
+ ```
20
68
 
21
- Coming Soon!
22
69
 
23
70
  Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
24
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/exists",
3
- "version": "4.13.20",
3
+ "version": "4.13.21",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "exists",