JSPM

@js-utilities/typecheck

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 831
  • Score
    100M100P100Q100082F
  • License MIT

Utility library for javascript type checking.

Package Exports

  • @js-utilities/typecheck

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 (@js-utilities/typecheck) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Type checking library

A set of super-simple type checkers. Each checker returns boolean value. Most checkers are typescript type predicates.

Installation

npm i -S @js-utilities/typecheck

Usage example

import { isBoolean } from "@js-utilities/typecheck";

const defaultValue = isBoolean(option.isEnabled) ? option.isEnabled : true;
import { isCallable } from "@js-utilities/typecheck";

const a: unknown = global.value;

if (isCallable(a)) a();

Available checkers:

Checker Return type
isCallable boolean
isFunction value is Function
isArrowFunction boolean
isArray<T> value is T[]
isObject<T> value is T
isBoolean value is boolean
isUndefined value is undefined
isNumber value is number
isString value is string
isSymbol value is symbol
isNull value is null
isMap<T, U> value is Map<T, U>
isSet<T> value is Set<T>
isWeakSet<T> value is WeakSet<T>
isWeakMap<T, U> value is WeakMap<T, U>

License

MIT License