(u: unknown): u is FileReturns true if a value is a File handle by checking for the
FileTypeId marker.
When to use
Use when accepting an unknown value and you need to narrow it to a File
before calling file-handle operations.
Details
This is a structural marker check. It does not validate the marker value or the shape of the file handle.
export const const isFile: (u: unknown) => u is FileReturns true if a value is a File handle by checking for the
FileTypeId marker.
When to use
Use when accepting an unknown value and you need to narrow it to a File
before calling file-handle operations.
Details
This is a structural marker check. It does not validate the marker value or
the shape of the file handle.
isFile = (u: unknownu: unknown): u: unknownu is File => hasProperty<"~effect/platform/FileSystem/File">(self: unknown, property: "~effect/platform/FileSystem/File"): self is { [K in "~effect/platform/FileSystem/File"]: 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 FileTypeId: "~effect/platform/FileSystem/File"Runtime type identifier attached to FileSystem.File handles and used by
isFile to recognize them.
Details
This marker is part of the runtime representation of file handles. Prefer
isFile when narrowing unknown values.
FileTypeId)