@xylabs/assert
Advanced tools
Comparing version 3.0.15 to 3.0.16
@@ -53,4 +53,4 @@ { | ||
"sideEffects": false, | ||
"version": "3.0.15", | ||
"version": "3.0.16", | ||
"type": "module" | ||
} |
@@ -39,7 +39,26 @@ [![logo][]](https://xylabs.com) | ||
## Documentation | ||
[Developer Reference](https://xylabs.github.io/sdk-js) | ||
## Usage | ||
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. | ||
Here are some examples of how to use `assertEx` in different scenarios: | ||
- Basic usage: | ||
```javascript | ||
import { assertEx } from '@xylabs/assert'; | ||
const value = getValue(); // This is a function that may return null or undefined | ||
assertEx(value); // Throws an AssertExError with a default message if value is null or undefined | ||
``` | ||
- Using with a custom error message: | ||
```javascript | ||
import { assertEx } from '@xylabs/assert'; | ||
const value = getValue(); // This function may return null or undefined | ||
assertEx(value, () => 'Dynamic error message based on some conditions'); // Throws an AssertExError with a dynamic message if value is null or undefined | ||
## Maintainers | ||
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com)) | ||
@@ -46,0 +65,0 @@ - [Joel Carter](https://github.com/JoelBCarter) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32766
88