Hyperlinkv0.8.0-beta.28

Predicate

Predicate.isObjectfunctioneffect/Predicate.ts:1033
(input: unknown): input is { [x: PropertyKey]: unknown }

Checks whether a value is a non-null object value that is not an array.

When to use

Use to narrow unknown input to a non-null, non-array object with a Predicate guard.

Details

This is a structural runtime check using typeof input === "object", so it also accepts object instances such as Date, Map, class instances, and typed arrays. It excludes null and arrays.

Example (Guarding objects)

import { Predicate } from "effect"

console.log(Predicate.isObject({ a: 1 }))
console.log(Predicate.isObject([1, 2]))
export function isObject(input: unknown): input is { [x: PropertyKey]: unknown } {
  return typeof input === "object" && input !== null && !Array.isArray(input)
}
Referenced by 7 symbols