@visulima/fs
Version:
Human friendly file system utilities for Node.js
86 lines (82 loc) • 3.47 kB
text/typescript
import { PathLike, Dirent } from 'node:fs';
import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions } from 'yaml';
declare const F_OK = 0;
declare const R_OK = 4;
declare const W_OK = 2;
declare const X_OK = 1;
declare const FIND_UP_STOP: unique symbol;
type ColorizeMethod = (value: string) => string;
interface WalkOptions {
extensions?: string[];
followSymlinks?: boolean;
includeDirs?: boolean;
includeFiles?: boolean;
includeSymlinks?: boolean;
match?: (RegExp | string)[];
maxDepth?: number;
skip?: (RegExp | string)[];
}
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
path: string;
}
type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
type ReadFileOptions<C> = {
buffer?: boolean;
compression?: C;
encoding?: ReadFileEncoding | undefined;
flag?: number | string | undefined;
};
type ContentType<O = undefined> = O extends {
buffer: true;
} ? Buffer : string;
type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
type CodeFrameLocation = {
column?: number;
line: number;
};
type CodeFrameOptions = {
color?: {
gutter?: ColorizeMethod;
marker?: ColorizeMethod;
message?: ColorizeMethod;
};
};
type ReadJsonOptions = CodeFrameOptions & {
beforeParse?: (source: string) => string;
};
type WriteFileOptions = {
chown?: {
gid: number;
uid: number;
};
encoding?: BufferEncoding | null | undefined;
flag?: string | undefined;
mode?: number;
overwrite?: boolean;
recursive?: boolean;
};
type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
type YamlReplacer = JsonReplacer;
type WriteJsonOptions = WriteFileOptions & {
detectIndent?: boolean;
indent?: number | string | undefined;
replacer?: JsonReplacer;
stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
};
type FindUpOptions = {
allowSymlinks?: boolean;
cwd?: URL | string;
stopAt?: URL | string;
type?: "directory" | "file";
};
type FindUpNameFnResult = PathLike | Promise<PathLike | typeof FIND_UP_STOP> | typeof FIND_UP_STOP | undefined;
type FindUpName = string[] | string | ((directory: string) => FindUpNameFnResult);
type FindUpNameSyncFnResult = PathLike | typeof FIND_UP_STOP | undefined;
type FindUpNameSync = string[] | string | ((directory: string) => FindUpNameSyncFnResult);
type EmptyDirOptions = {
maxRetries?: number | undefined;
retryDelay?: number | undefined;
};
type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
type YamlReviver = (key: unknown, value: unknown) => unknown;
export { type ContentType as C, type EmptyDirOptions as E, type FindUpName as F, type JsonReviver as J, type ReadFileOptions as R, type WalkOptions as W, X_OK as X, type YamlReviver as Y, type FindUpOptions as a, type FindUpNameSync as b, type WalkEntry as c, type ReadJsonOptions as d, type WriteFileOptions as e, type WriteJsonOptions as f, F_OK as g, FIND_UP_STOP as h, R_OK as i, W_OK as j, type CodeFrameLocation as k, type FindUpNameFnResult as l, type FindUpNameSyncFnResult as m, type JsonReplacer as n, type ReadFileEncoding as o, type CodeFrameOptions as p, type ReadYamlOptions as q, type YamlReplacer as r };