@tool-belt/type-predicates

Collection of performant type-guard utilities

Usage no npm install needed!

<script type="module">
  import toolBeltTypePredicates from 'https://cdn.skypack.dev/@tool-belt/type-predicates';
</script>

README

Tests Coverage Quality Gate Status Security Rating Reliability Rating Maintainability Rating

@tool-belt/type-predicates

Installation

npm install @tool-belt/type-predicates

Or

yarn add @tool-belt/type-predicates

Contents

This package includes the following:

  • a comprehensive collection of performant and flexible type-guards, that can function as a drop-in replacement for the type-guards included in the NodeJS builtin utils/types module - with better significantly typing.
  • a comprehensive collection of type assertions covering all type-guards included in the package.
  • isUnion, createTypeGuard and createTypeAssertion utilities for the composition of type-guards and assertions.
  • supports ES modules and tree shaking, i.e., works great with module bundlers such as Webpack for the browser.

See the docs for details.