@xylabs/assert 3.0.15 → 3.0.16

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 +22 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -36,11 +36,30 @@ Using yarn:
36
36
  yarn add @xylabs/assert
37
37
  ```
38
38
 
39
- ## Documentation
40
- [Developer Reference](https://xylabs.github.io/sdk-js)
39
+ ## Usage
41
40
 
42
- ## Maintainers
41
+ The `assertEx` function is a utility function for simple null/undefined checks for variables. It evaluates an expression for truthiness and throws an error if the expression is false.
42
+
43
+ Here are some examples of how to use `assertEx` in different scenarios:
44
+
45
+ - Basic usage:
46
+
47
+ ```javascript
48
+ import { assertEx } from '@xylabs/assert';
49
+
50
+ const value = getValue(); // This is a function that may return null or undefined
51
+ assertEx(value); // Throws an AssertExError with a default message if value is null or undefined
52
+ ```
43
53
 
54
+ - Using with a custom error message:
55
+
56
+ ```javascript
57
+ import { assertEx } from '@xylabs/assert';
58
+
59
+ const value = getValue(); // This function may return null or undefined
60
+ assertEx(value, () => 'Dynamic error message based on some conditions'); // Throws an AssertExError with a dynamic message if value is null or undefined
61
+
62
+ ## Maintainers
44
63
  - [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
45
64
  - [Joel Carter](https://github.com/JoelBCarter)
46
65
  - [Matt Jones](https://github.com/jonesmac)
package/package.json CHANGED
@@ -50,6 +50,6 @@
50
50
  "url": "https://github.com/xylabs/sdk-js.git"
51
51
  },
52
52
  "sideEffects": false,
53
- "version": "3.0.15",
53
+ "version": "3.0.16",
54
54
  "type": "module"
55
55
  }