Skip to content
tsdotnetPublic

About

A set of useful utility functions for JavaScript run-time type checking and inspection.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

@tsdotnet/type: Check types at run time. Guards that narrow, not just test.

npm version GitHub license

Type guards and checks for JavaScript values, collected in one type namespace.

Install

npm install @tsdotnet/type

Usage

import { type } from '@tsdotnet/type';

declare const value: unknown;
if (type.isString(value)) value.toUpperCase(); // narrowed to string

type.isNumber(NaN); // true
type.isNumber(NaN, true); // false: NaN ignored

Also isFunction, isObject, isIterable, hasMember and more, all as type guards.

Use it from

ESM (import { type } from '@tsdotnet/type';) or CommonJS (const { type } = require('@tsdotnet/type');).

In a browser, without a bundler
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/type@1/dist/umd/type.min.js"></script>
<script>
  const { type } = tsdotnet.type;
</script>

Docs

tsdotnet.github.io/type

About

A set of useful utility functions for JavaScript run-time type checking and inspection.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages