0.1.0 • Published 4 months ago

type-guarden v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

type-guarden 🌱

Collection of type guards for TypeScript.

Installation

npm install type-guarden

Usage

import { isKeyOf, isElementOf } from 'type-guarden'

const obj = {
  foo: 'bar',
  baz: 42,
}

const arr = ['foo', 'bar', 'baz']

let key: unknown
let element: unknown

if (isKeyOf(obj, key)) {
  // `key` is 'foo' | 'baz'
}

if (isElementOf(arr, element)) {
  // `element` is 'foo' | 'bar' | 'baz'
}

APIs

  • isKeyOf
  • isElementOf
  • isBigInt
  • isBoolean
  • isNull
  • isNumber
  • isString
  • isSymbol
  • isUndefined
  • isFunction
  • isObject
  • isPlainObject
  • isPromise
  • isPrimitive
  • isTruthy
  • isFalsy
0.1.0

4 months ago

0.0.2

1 year ago

0.0.1

1 year ago