Hyperlinkv0.8.0-beta.28

Predicate

Predicate.isObjectOrArrayfunctioneffect/Predicate.ts:1001
(input: unknown): input is { [x: PropertyKey]: unknown } | Array<unknown>

Checks whether a value is an object or an array (non-null object).

When to use

Use when you need a Predicate guard that accepts plain objects and arrays, but not null.

Details

Uses typeof input === "object" && input !== null and includes arrays.

Example (Checking objects or arrays)

import { Predicate } from "effect"

console.log(Predicate.isObjectOrArray([]))
export function isObjectOrArray(input: unknown): input is { [x: PropertyKey]: unknown } | Array<unknown> {
  return typeof input === "object" && input !== null
}