uft
    Preparing search index...

    Function isObject

    • Checks if a value is typeof object and not null or an array.

      Type Parameters

      • T

      Parameters

      • value: T

        The value to check.

      Returns value is T extends Function | unknown[] ? never : T & object

      true if the check passes, false otherwise.

      This function will return false for an array. If you do not want this behavior, use isObjectLoose instead.

      isObject({}) // true
      isObject([]) // false
      isObject(null) // false
      const value: { foo: string } | string[]

      if (isObject(value)) {
      value // type: { foo: string }
      } else {
      value // type: string[]
      }

      // works with function too
      const value: { foo: string } | (() => string)

      if (isObject(value)) {
      value // type: { foo: string }
      value.foo // ok
      } else {
      value // (() => string)
      value() // ok
      }
      import { assert } from 'uft'

      const options: { opt: string } | string[]
      assert(isObject(options), 'expected options object')
      options // type: { opt: string }