(): booleanReturns true when called.
When to use
Use when you need a thunk that returns true on every invocation.
Example (Returning true from a thunk)
import { Function } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Function.constTrue(), true)constants
Source effect/Function.ts:3451 lines
export const const constTrue: LazyArg<boolean>Returns true when called.
When to use
Use when you need a thunk that returns true on every invocation.
Example (Returning true from a thunk)
import { Function } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(Function.constTrue(), true)
constTrue: type LazyArg<A> = () => AA zero-argument function that produces a value when invoked.
When to use
Use to type a lazy value provider that should not run until called.
Example (Creating a lazy argument)
import { Function } from "effect"
const constNull: Function.LazyArg<null> = Function.constant(null)
LazyArg<boolean> = const constant: <A>(
value: A
) => LazyArg<A>
Creates a zero-argument function that always returns the provided value.
When to use
Use when you need a thunk or callback that returns the same value on every
invocation.
Example (Creating a constant thunk)
import { Function } from "effect"
import * as assert from "node:assert"
const constNull = Function.constant(null)
assert.deepStrictEqual(constNull(), null)
assert.deepStrictEqual(constNull(), null)
constant(true)Referenced by 7 symbols