@visulima/fs
Version:
Human friendly file system utilities for Node.js
90 lines (86 loc) • 3.73 kB
text/typescript
import { PathLike, Dirent } from 'node:fs';
import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, CreateNodeOptions, ToStringOptions } 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 RetryOptions = {
maxRetries?: number | undefined;
retryDelay?: number | undefined;
};
type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
type YamlReviver = (key: unknown, value: unknown) => unknown;
type WriteYamlOptions = WriteFileOptions & CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions & {
replacer?: YamlReplacer;
space?: number | string;
};
export { type ContentType as C, 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 RetryOptions as e, type WriteFileOptions as f, type WriteJsonOptions as g, F_OK as h, FIND_UP_STOP as i, R_OK as j, W_OK as k, type CodeFrameLocation as l, type CodeFrameOptions as m, type FindUpNameFnResult as n, type FindUpNameSyncFnResult as o, type JsonReplacer as p, type ReadFileEncoding as q, type ReadYamlOptions as r, type WriteYamlOptions as s, type YamlReplacer as t };