Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bitty/nullish

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitty/nullish

Nullish helper functions and types for TypeScript.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by41.67%
Maintainers
2
Weekly downloads
 
Created
Source

@bitty/nullish

Bundle minified size Bundle minified and gzipped size

Nullish helper functions and types for TypeScript.

  • 📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.

  • ⚡ Lightweight:

    • Weighs less than 0.2KB (min + gzip).
    • Tree-shakeable.
    • Side-effects free.
  • 🔋 Bateries included:

    • No dependencies.
    • Its not based on newer browser's APIs or es2015+ features.
  • 🏷 Safe:

    • JSDocs and type declarations for IDEs and editor's autocomplete/intellisense.
    • Made with TypeScript as strict as possible.
    • Unit tests with AVA.

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @bitty/nullish --save

# For Yarn, use the command below.
yarn add @bitty/nullish

Installation from CDN

This module has a UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/@bitty/nullish"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/@bitty/nullish"></script>

<script>
  // UMD module is exposed through the "isNullish" global function.
  console.log(isNullish);
  //=> "[Function: isNullish]"

  console.log(isNullish(null));
  //=> true
</script>

Getting Stated

This module default exports isNullish, which is a predicate function that checks if value is nullish.

import isNullish from '@bitty/pipe';

isNullish(null);
//=> true

isNullish(undefined);
//=> true

isNullish(undefined as void);
//=> true

isNullish(NaN);
//=> false

We also exports NonNullish and Nullish types.

  • Nullish is simply an union of null, void and undefined types.

    import { Nullish } from '@bitty/nullish';
    
    let nullish: Nullish;
    nullish = null;
    nullish = undefined;
    nullish = undefined as void;
    
    nullish = false;
    //=> throws "Type 'false' is not assignable to type 'Nullish'.".
    
  • NonNullish<T> is a type helper that removes nullish types.

    import { NonNullish } from '@bitty/nullish';
    
    type Value = string | null | undefined;
    
    const value: NonNullish<Value> = null;
    //=> throws "Type 'null' is not assignable to type 'string'.".
    

License

Released under MIT License.

Keywords

FAQs

Package last updated on 06 Sep 2020

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc