@ayonli/jsext
Version:
A JavaScript extension package for building strong and modern applications.
32 lines (31 loc) • 1.37 kB
TypeScript
import { Exception } from "../error.ts";
import type { DirEntry } from "./types.ts";
export declare function ensureFsTarget<T extends string | URL | FileSystemFileHandle | FileSystemDirectoryHandle>(path: T): string | Exclude<T, URL>;
/**
* Wraps a raw file system error to a predefined error by this module.
*
* @param type Used for `FileSystemHandle` operations.
*/
export declare function wrapFsError(err: unknown, type?: "file" | "directory" | undefined): Exception | Error;
/**
* Wraps a raw file system operation so that when any error occurs, the error is
* wrapped to a predefined error by this module.
*
* @param type Only used for `FileSystemHandle` operations.
*/
export declare function rawOp<T>(op: Promise<T>, type?: "file" | "directory" | undefined): Promise<T>;
export declare function fixDirEntry<T extends DirEntry>(entry: T): T;
export declare function fixFileType(file: File): File;
type CompatDirEntry = Omit<DirEntry, "kind"> & {
kind: string;
};
type CompatDirTree = Omit<DirEntry, "kind"> & {
kind: string;
children?: CompatDirTree[];
};
/**
* @param addPathProp `DirEntry.prop` is deprecated, this option is for backward
* compatibility.
*/
export declare function makeTree<I extends CompatDirEntry, R extends CompatDirTree>(dir: string | FileSystemDirectoryHandle, entries: I[], addPathProp?: boolean): R;
export {};