Package Exports
- ccax
- ccax/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ccax) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
CCAX
Overview
This project is to utilize when we want to assert some params, it can be string, number or any instance of any class. The motivation behind this is to avoid if-else chains just to validate the parameters. see https://stackoverflow.com/q/73795540/2961427 for more details.
Use Case:
- We can use this library to safeguard any methods before actual logic execution
- It can reduce
if-elsechain anywhere in the code by pre-asserting the required/optional parameters.
How to Use
First, you will have to install the
CCAXnpm i ccaxYou will have to require the
CCAXimport ccax from 'ccax'; // Start using it. ccax.assertString('String Value'); // Will not throw any error, as it's a valid string
or if you are using node with require, use the below example"
const ccax = require('ccax').default; // Start using it. ccax.assertString(true, 'name'); // Throws the Error: `Param name must be a String` because value is boolean
You can use try catch for better error handling.