JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q25856F
  • License MIT

This library will help to assert the parameters, instances, classes, functions, primitive/non-primitive types

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.

GitHub license npm version PRs Welcome Download

Use Case:

  1. We can use this library to safeguard any methods before actual logic execution
  2. It can reduce if-else chain anywhere in the code by pre-asserting the required/optional parameters.

How to Use

  1. First, you will have to install the CCAX

      npm i ccax
  2. You will have to require the CCAX

      import 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
  3. You can use try catch for better error handling.

Note: More example easy/complex will be added soon