(input: unknown): input is objectChecks whether a value is an object in the JavaScript sense (objects, arrays, functions).
When to use
Use when you need a Predicate guard that accepts arrays and functions as
well as objects.
Details
Returns true for arrays and functions, and false for null.
Example (Checking object keywords)
import { Predicate } from "effect"
console.log(Predicate.isObjectKeyword(() => 1))
console.log(Predicate.isObjectKeyword(null))export function function isObjectKeyword(
input: unknown
): input is object
Checks whether a value is an object in the JavaScript sense (objects, arrays, functions).
When to use
Use when you need a Predicate guard that accepts arrays and functions as
well as objects.
Details
Returns true for arrays and functions, and false for null.
Example (Checking object keywords)
import { Predicate } from "effect"
console.log(Predicate.isObjectKeyword(() => 1))
console.log(Predicate.isObjectKeyword(null))
isObjectKeyword(input: unknowninput: unknown): input: unknowninput is object {
return (typeof input: unknowninput === "object" && input: object | nullinput !== null) || function isFunction(
input: unknown
): input is Function
Checks whether a value is a function.
When to use
Use when you need a Predicate guard to narrow an unknown value to a
callable function.
Details
Uses typeof input === "function".
Example (Guarding functions)
import { Predicate } from "effect"
const data: unknown = () => 1
if (Predicate.isFunction(data)) {
console.log(data())
}
isFunction(input: unknowninput)
}