Target.ts overview
How a caller names what it operates on. A Target is a path, an object
reference, or an open handle; an Entry is a child of a directory target
called name. Every verb takes one or the other, so the three addressing
modes share one body and one option vocabulary.
Since v0.6.0
constructors
Entry
Names a child of a directory. The directory may be given bare.
Example
import { Entry, Target } from "@effect-vfs/core/Target"
const explicit = Entry(Target.Path({ path: "/var" }), "log")
const bare = Entry("/var", "log")Signature
declare const Entry: {
(name: NameInput): (directory: TargetInput) => Entry
(directory: TargetInput, name: NameInput): Entry
}Since v0.6.0
Target
Constructors and matchers for Target, plus of, which wraps a bare path,
reference, or handle.
Signature
declare const Target: {
readonly Path: Data.TaggedEnum.ConstructorFrom<
{
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
},
"_tag"
>
readonly Reference: Data.TaggedEnum.ConstructorFrom<
{ readonly _tag: "Reference"; readonly reference: ObjectReference },
"_tag"
>
readonly Handle: Data.TaggedEnum.ConstructorFrom<
{ readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle },
"_tag"
>
readonly $is: <Tag extends "Path" | "Reference" | "Handle">(
tag: Tag
) => (
u: unknown
) => u is
| Extract<
{
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
},
{ readonly _tag: Tag }
>
| Extract<{ readonly _tag: "Reference"; readonly reference: ObjectReference }, { readonly _tag: Tag }>
| Extract<{ readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle }, { readonly _tag: Tag }>
readonly $match: {
<
Cases extends {
readonly Path: (args: {
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
}) => any
readonly Reference: (args: { readonly _tag: "Reference"; readonly reference: ObjectReference }) => any
readonly Handle: (args: { readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle }) => any
}
>(
cases: Cases
): (
value:
| {
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
}
| { readonly _tag: "Reference"; readonly reference: ObjectReference }
| { readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle }
) => Unify<ReturnType<Cases["Path" | "Reference" | "Handle"]>>
<
Cases extends {
readonly Path: (args: {
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
}) => any
readonly Reference: (args: { readonly _tag: "Reference"; readonly reference: ObjectReference }) => any
readonly Handle: (args: { readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle }) => any
}
>(
value:
| {
readonly _tag: "Path"
readonly path: PathInput
readonly relativeTo?: DirectoryHandle
readonly followFinalSymlink?: boolean
}
| { readonly _tag: "Reference"; readonly reference: ObjectReference }
| { readonly _tag: "Handle"; readonly handle: FileHandle | DirectoryHandle },
cases: Cases
): Unify<ReturnType<Cases["Path" | "Reference" | "Handle"]>>
}
} & { readonly of: (input: TargetInput) => Target }Since v0.6.0
models
Entry (interface)
A child of a directory target, called name.
Signature
export interface Entry {
readonly directory: Target
readonly name: NameInput
}Since v0.6.0
EntryInput (type alias)
Anything a verb accepts where it takes an entry: an Entry, or a path (bare
or as a path target with a base) whose final component is the name and
whose prefix is the directory.
Signature
type EntryInput = Entry | PathInput | PathTargetSince v0.6.0
Name (type alias)
A well-formed entry name, as bytes.
Signature
export type Name = Uint8Array<ArrayBufferLike>Since v0.6.0
NameInput (type alias)
A directory entry name as bytes or as a string encoded as UTF-8: one to 255
bytes with no NUL and no slash. . and .. are well formed but reserved.
Signature
type NameInput = string | Uint8ArraySince v0.6.0
PathTarget (type alias)
The path variant of Target.
Signature
type PathTarget = Extract<Target, { readonly _tag: "Path" }>Since v0.6.0
Target (type alias)
A target: a path resolved from the caller's working directory or a base handle, an object reference, or an open handle.
Signature
type Target = Data.TaggedEnum<{
readonly Path: {
readonly path: PathInput
/** A live directory handle from the same volume that a relative path starts from. */
readonly relativeTo?: DirectoryHandle
/** Whether a final symbolic link is followed. Defaults to `true`. */
readonly followFinalSymlink?: boolean
}
readonly Reference: { readonly reference: ObjectReference }
readonly Handle: { readonly handle: FileHandle | DirectoryHandle }
}>Since v0.6.0
TargetInput (type alias)
Anything a verb accepts where it takes a target: a Target, or the bare
path, reference, or handle it would wrap.
Signature
type TargetInput = Target | PathInput | ObjectReference | FileHandle | DirectoryHandleSince v0.6.0
predicates
isBytePathInput
Whether a path input is a byte path rather than a string.
Signature
declare const isBytePathInput: (input: PathInput) => booleanSince v0.6.0
isEntry
Whether a value is an Entry.
Signature
declare const isEntry: (value: unknown) => value is EntrySince v0.6.0
isTarget
Whether a value is a Target.
Signature
declare const isTarget: (value: unknown) => value is TargetSince v0.6.0
schemas
Name
Schema for a well-formed entry name, as bytes.
Signature
declare const Name: Schema.Uint8ArraySince v0.6.0