(u: unknown): u is CronChecks whether a given value is a Cron instance.
When to use
Use to narrow an unknown value before treating it as a Cron schedule.
Details
This function is a type guard that determines whether the provided value is a valid Cron instance by checking for the presence of the Cron type identifier.
Example (Checking cron values)
import { Cron } from "effect"
const cron = Cron.make({
minutes: [0],
hours: [9],
days: [1, 15],
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
weekdays: [1, 2, 3, 4, 5]
})
console.log(Cron.isCron(cron)) // true
console.log(Cron.isCron({})) // false
console.log(Cron.isCron("not a cron")) // falseexport const const isCron: (u: unknown) => u is CronChecks whether a given value is a Cron instance.
When to use
Use to narrow an unknown value before treating it as a Cron schedule.
Details
This function is a type guard that determines whether the provided
value is a valid Cron instance by checking for the presence of the
Cron type identifier.
Example (Checking cron values)
import { Cron } from "effect"
const cron = Cron.make({
minutes: [0],
hours: [9],
days: [1, 15],
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
weekdays: [1, 2, 3, 4, 5]
})
console.log(Cron.isCron(cron)) // true
console.log(Cron.isCron({})) // false
console.log(Cron.isCron("not a cron")) // false
isCron = (u: unknownu: unknown): u: unknownu is Cron => hasProperty<"~effect/time/Cron">(self: unknown, property: "~effect/time/Cron"): self is { [K in "~effect/time/Cron"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const TypeId: "~effect/time/Cron"TypeId)