(input: unknown): input is { readonly [x: PropertyKey]: unknown }Checks whether a value is a non-null, non-array object and narrows it to a readonly indexable object type.
When to use
Use to narrow unknown input to a readonly view of a non-null, non-array
object with a Predicate guard.
Details
Readonly-ness is a TypeScript type-level view; it is not observable at
runtime. This delegates to isObject, so class instances and built-in object
instances are accepted.
Example (Checking readonly objects)
import { Predicate } from "effect"
const data: unknown = { a: 1 }
console.log(Predicate.isReadonlyObject(data))export function function isReadonlyObject(
input: unknown
): input is {
readonly [x: PropertyKey]: unknown
}
Checks whether a value is a non-null, non-array object and narrows it to a
readonly indexable object type.
When to use
Use to narrow unknown input to a readonly view of a non-null, non-array
object with a Predicate guard.
Details
Readonly-ness is a TypeScript type-level view; it is not observable at
runtime. This delegates to isObject, so class instances and built-in object
instances are accepted.
Example (Checking readonly objects)
import { Predicate } from "effect"
const data: unknown = { a: 1 }
console.log(Predicate.isReadonlyObject(data))
isReadonlyObject(input: unknowninput: unknown): input: unknowninput is { readonly [x: PropertyKeyx: type PropertyKey =
| string
| number
| symbol
PropertyKey]: unknown } {
return function isObject(
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]))
isObject(input: unknowninput)
}