Hyperlinkv0.8.0-beta.28

Predicate

Predicate.isPromiseLikefunctioneffect/Predicate.ts:1347
(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
export function isPromiseLike(input: unknown): input is PromiseLike<unknown> {
  return hasProperty(input, "then") && isFunction(input.then)
}