Socket
Socket
Sign inDemoInstall

@xylabs/assert

Package Overview
Dependencies
0
Maintainers
5
Versions
192
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/assert


Version published
Maintainers
5
Created

Readme

Source

logo

@xylabs/assert

npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge socket-badge

XY Labs generalized Javascript library

Table of Contents

Description

Common Javascript code that is used throughout XYO projects that use React.

Install

Using npm:

npm i --save @xylabs/assert

Using yarn:

yarn add @xylabs/assert

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:

    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:

    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

License

See the LICENSE file for license details

Credits

Made with 🔥and ❄️ by XY Labs

Keywords

FAQs

Last updated on 23 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc