ts-is-record
TypeScript icon, indicating that this package has built-in type declarations

3.0.5 • Public • Published

ts-is-record

npm build publish Libraries.io dependency status for latest release Bundlephobia npm

Typescript utilities

import invariant from 'ts-tiny-invariant'

type Key = string | number | symbol

export function isRecord(value: unknown): value is Record<Key, unknown> {
  return (
    value !== null &&
    (typeof value === 'object' || typeof value === 'function') &&
    !Array.isArray(value)
  )
}

export function assertRecord(
  value: unknown,
  message: string
): asserts value is Record<Key, unknown> {
  invariant(isRecord(value), message)
}

Readme

Keywords

Package Sidebar

Install

npm i ts-is-record

Weekly Downloads

65

Version

3.0.5

License

MIT

Unpacked Size

6.6 kB

Total Files

10

Last publish

Collaborators

  • iyegoroff