(input: unknown): input is PromiseLike<unknown>Checks whether a value is PromiseLike (has a then method).
When to use
Use when you need a Predicate guard for promise-like values with a
callable then method.
Details
Performs a structural check for a callable then.
Example (Guarding promise-like values)
import { Predicate } from "effect"
const data: unknown = { then: () => {} }
console.log(Predicate.isPromiseLike(data))guardsisPromise
Source effect/Predicate.ts:13473 lines
export function function isPromiseLike(
input: unknown
): input is PromiseLike<unknown>
Checks whether a value is PromiseLike (has a then method).
When to use
Use when you need a Predicate guard for promise-like values with a
callable then method.
Details
Performs a structural check for a callable then.
Example (Guarding promise-like values)
import { Predicate } from "effect"
const data: unknown = { then: () => {} }
console.log(Predicate.isPromiseLike(data))
isPromiseLike(input: unknowninput: unknown): input: unknowninput is interface PromiseLike<T>PromiseLike<unknown> {
return const hasProperty: <"then">(self: unknown, property: "then") => self is { [K in "then"]: unknown; } (+1 overload)hasProperty(input: unknowninput, "then") && 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: {
then: unknown
}
input.then: unknownthen)
}