Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
import type * as opts from './types/options';
import type { IFileHandle, IReadStream, IWriteStream, IStats, TData, TDataOut, TMode, TTime } from './types/misc';
import type { FsCallbackApi } from './types';
export declare class FileHandle implements IFileHandle {
private fs;
fd: number;
constructor(fs: FsCallbackApi, fd: number);
appendFile(data: TData, options?: opts.IAppendFileOptions | string): Promise<void>;
chmod(mode: TMode): Promise<void>;
chown(uid: number, gid: number): Promise<void>;
close(): Promise<void>;
datasync(): Promise<void>;
createReadStream(options: opts.IFileHandleReadStreamOptions): IReadStream;
createWriteStream(options: opts.IFileHandleWriteStreamOptions): IWriteStream;
readableWebStream(options?: opts.IReadableWebStreamOptions): ReadableStream;
read(buffer: Buffer | Uint8Array, offset: number, length: number, position: number): Promise<TFileHandleReadResult>;
readv(buffers: ArrayBufferView[], position?: number | null | undefined): Promise<TFileHandleReadvResult>;
readFile(options?: opts.IReadFileOptions | string): Promise<TDataOut>;
stat(options?: opts.IFStatOptions): Promise<IStats>;
sync(): Promise<void>;
truncate(len?: number): Promise<void>;
utimes(atime: TTime, mtime: TTime): Promise<void>;
write(buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number): Promise<TFileHandleWriteResult>;
writev(buffers: ArrayBufferView[], position?: number | null | undefined): Promise<TFileHandleWritevResult>;
writeFile(data: TData, options?: opts.IWriteFileOptions): Promise<void>;
}
export interface TFileHandleReadResult {
bytesRead: number;
buffer: Buffer | Uint8Array;
}
export interface TFileHandleWriteResult {
bytesWritten: number;
buffer: Buffer | Uint8Array;
}
export interface TFileHandleReadvResult {
bytesRead: number;
buffers: ArrayBufferView[];
}
export interface TFileHandleWritevResult {
bytesWritten: number;
buffers: ArrayBufferView[];
}
+72
View File
@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileHandle = void 0;
const util_1 = require("./util");
class FileHandle {
constructor(fs, fd) {
this.fs = fs;
this.fd = fd;
}
appendFile(data, options) {
return (0, util_1.promisify)(this.fs, 'appendFile')(this.fd, data, options);
}
chmod(mode) {
return (0, util_1.promisify)(this.fs, 'fchmod')(this.fd, mode);
}
chown(uid, gid) {
return (0, util_1.promisify)(this.fs, 'fchown')(this.fd, uid, gid);
}
close() {
return (0, util_1.promisify)(this.fs, 'close')(this.fd);
}
datasync() {
return (0, util_1.promisify)(this.fs, 'fdatasync')(this.fd);
}
createReadStream(options) {
return this.fs.createReadStream('', Object.assign(Object.assign({}, options), { fd: this }));
}
createWriteStream(options) {
return this.fs.createWriteStream('', Object.assign(Object.assign({}, options), { fd: this }));
}
readableWebStream(options) {
return new ReadableStream({
pull: async (controller) => {
const data = await this.readFile();
controller.enqueue(data);
controller.close();
},
});
}
read(buffer, offset, length, position) {
return (0, util_1.promisify)(this.fs, 'read', bytesRead => ({ bytesRead, buffer }))(this.fd, buffer, offset, length, position);
}
readv(buffers, position) {
return (0, util_1.promisify)(this.fs, 'readv', bytesRead => ({ bytesRead, buffers }))(this.fd, buffers, position);
}
readFile(options) {
return (0, util_1.promisify)(this.fs, 'readFile')(this.fd, options);
}
stat(options) {
return (0, util_1.promisify)(this.fs, 'fstat')(this.fd, options);
}
sync() {
return (0, util_1.promisify)(this.fs, 'fsync')(this.fd);
}
truncate(len) {
return (0, util_1.promisify)(this.fs, 'ftruncate')(this.fd, len);
}
utimes(atime, mtime) {
return (0, util_1.promisify)(this.fs, 'futimes')(this.fd, atime, mtime);
}
write(buffer, offset, length, position) {
return (0, util_1.promisify)(this.fs, 'write', bytesWritten => ({ bytesWritten, buffer }))(this.fd, buffer, offset, length, position);
}
writev(buffers, position) {
return (0, util_1.promisify)(this.fs, 'writev', bytesWritten => ({ bytesWritten, buffers }))(this.fd, buffers, position);
}
writeFile(data, options) {
return (0, util_1.promisify)(this.fs, 'writeFile')(this.fd, data, options);
}
}
exports.FileHandle = FileHandle;
//# sourceMappingURL=FileHandle.js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import type * as misc from './types/misc';
import type { FsCallbackApi, FsPromisesApi } from './types';
export declare class FsPromises implements FsPromisesApi {
protected readonly fs: FsCallbackApi;
readonly FileHandle: new (...args: unknown[]) => misc.IFileHandle;
readonly constants: {
O_RDONLY: number;
O_WRONLY: number;
O_RDWR: number;
S_IFMT: number;
S_IFREG: number;
S_IFDIR: number;
S_IFCHR: number;
S_IFBLK: number;
S_IFIFO: number;
S_IFLNK: number;
S_IFSOCK: number;
O_CREAT: number;
O_EXCL: number;
O_NOCTTY: number;
O_TRUNC: number;
O_APPEND: number;
O_DIRECTORY: number;
O_NOATIME: number;
O_NOFOLLOW: number;
O_SYNC: number;
O_SYMLINK: number;
O_DIRECT: number;
O_NONBLOCK: number;
S_IRWXU: number;
S_IRUSR: number;
S_IWUSR: number;
S_IXUSR: number;
S_IRWXG: number;
S_IRGRP: number;
S_IWGRP: number;
S_IXGRP: number;
S_IRWXO: number;
S_IROTH: number;
S_IWOTH: number;
S_IXOTH: number;
F_OK: number;
R_OK: number;
W_OK: number;
X_OK: number;
UV_FS_SYMLINK_DIR: number;
UV_FS_SYMLINK_JUNCTION: number;
UV_FS_COPYFILE_EXCL: number;
UV_FS_COPYFILE_FICLONE: number;
UV_FS_COPYFILE_FICLONE_FORCE: number;
COPYFILE_EXCL: number;
COPYFILE_FICLONE: number;
COPYFILE_FICLONE_FORCE: number;
};
constructor(fs: FsCallbackApi, FileHandle: new (...args: unknown[]) => misc.IFileHandle);
readonly cp: (...args: any[]) => Promise<any>;
readonly opendir: (...args: any[]) => Promise<any>;
readonly statfs: (...args: any[]) => Promise<any>;
readonly lutimes: (...args: any[]) => Promise<any>;
readonly access: (...args: any[]) => Promise<any>;
readonly chmod: (...args: any[]) => Promise<any>;
readonly chown: (...args: any[]) => Promise<any>;
readonly copyFile: (...args: any[]) => Promise<any>;
readonly lchmod: (...args: any[]) => Promise<any>;
readonly lchown: (...args: any[]) => Promise<any>;
readonly link: (...args: any[]) => Promise<any>;
readonly lstat: (...args: any[]) => Promise<any>;
readonly mkdir: (...args: any[]) => Promise<any>;
readonly mkdtemp: (...args: any[]) => Promise<any>;
readonly readdir: (...args: any[]) => Promise<any>;
readonly readlink: (...args: any[]) => Promise<any>;
readonly realpath: (...args: any[]) => Promise<any>;
readonly rename: (...args: any[]) => Promise<any>;
readonly rmdir: (...args: any[]) => Promise<any>;
readonly rm: (...args: any[]) => Promise<any>;
readonly stat: (...args: any[]) => Promise<any>;
readonly symlink: (...args: any[]) => Promise<any>;
readonly truncate: (...args: any[]) => Promise<any>;
readonly unlink: (...args: any[]) => Promise<any>;
readonly utimes: (...args: any[]) => Promise<any>;
readonly readFile: (id: misc.TFileHandle, options?: opts.IReadFileOptions | string) => Promise<misc.TDataOut>;
readonly appendFile: (path: misc.TFileHandle, data: misc.TData, options?: opts.IAppendFileOptions | string) => Promise<void>;
readonly open: (path: misc.PathLike, flags?: misc.TFlags, mode?: misc.TMode) => Promise<any>;
readonly writeFile: (id: misc.TFileHandle, data: misc.TPromisesData, options?: opts.IWriteFileOptions) => Promise<void>;
readonly watch: () => never;
}
+55
View File
@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FsPromises = void 0;
const util_1 = require("./util");
const constants_1 = require("../constants");
class FsPromises {
constructor(fs, FileHandle) {
this.fs = fs;
this.FileHandle = FileHandle;
this.constants = constants_1.constants;
this.cp = (0, util_1.promisify)(this.fs, 'cp');
this.opendir = (0, util_1.promisify)(this.fs, 'opendir');
this.statfs = (0, util_1.promisify)(this.fs, 'statfs');
this.lutimes = (0, util_1.promisify)(this.fs, 'lutimes');
this.access = (0, util_1.promisify)(this.fs, 'access');
this.chmod = (0, util_1.promisify)(this.fs, 'chmod');
this.chown = (0, util_1.promisify)(this.fs, 'chown');
this.copyFile = (0, util_1.promisify)(this.fs, 'copyFile');
this.lchmod = (0, util_1.promisify)(this.fs, 'lchmod');
this.lchown = (0, util_1.promisify)(this.fs, 'lchown');
this.link = (0, util_1.promisify)(this.fs, 'link');
this.lstat = (0, util_1.promisify)(this.fs, 'lstat');
this.mkdir = (0, util_1.promisify)(this.fs, 'mkdir');
this.mkdtemp = (0, util_1.promisify)(this.fs, 'mkdtemp');
this.readdir = (0, util_1.promisify)(this.fs, 'readdir');
this.readlink = (0, util_1.promisify)(this.fs, 'readlink');
this.realpath = (0, util_1.promisify)(this.fs, 'realpath');
this.rename = (0, util_1.promisify)(this.fs, 'rename');
this.rmdir = (0, util_1.promisify)(this.fs, 'rmdir');
this.rm = (0, util_1.promisify)(this.fs, 'rm');
this.stat = (0, util_1.promisify)(this.fs, 'stat');
this.symlink = (0, util_1.promisify)(this.fs, 'symlink');
this.truncate = (0, util_1.promisify)(this.fs, 'truncate');
this.unlink = (0, util_1.promisify)(this.fs, 'unlink');
this.utimes = (0, util_1.promisify)(this.fs, 'utimes');
this.readFile = (id, options) => {
return (0, util_1.promisify)(this.fs, 'readFile')(id instanceof this.FileHandle ? id.fd : id, options);
};
this.appendFile = (path, data, options) => {
return (0, util_1.promisify)(this.fs, 'appendFile')(path instanceof this.FileHandle ? path.fd : path, data, options);
};
this.open = (path, flags = 'r', mode) => {
return (0, util_1.promisify)(this.fs, 'open', fd => new this.FileHandle(this.fs, fd))(path, flags, mode);
};
this.writeFile = (id, data, options) => {
const dataPromise = (0, util_1.isReadableStream)(data) ? (0, util_1.streamToBuffer)(data) : Promise.resolve(data);
return dataPromise.then(data => (0, util_1.promisify)(this.fs, 'writeFile')(id instanceof this.FileHandle ? id.fd : id, data, options));
};
this.watch = () => {
throw new Error('Not implemented');
};
}
}
exports.FsPromises = FsPromises;
//# sourceMappingURL=FsPromises.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FsPromises.js","sourceRoot":"","sources":["../../src/node/FsPromises.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AACrE,4CAAyC;AAKzC,MAAa,UAAU;IAGrB,YACqB,EAAiB,EACpB,UAAwD;QADrD,OAAE,GAAF,EAAE,CAAe;QACpB,eAAU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
CB: string;
UID: string;
GID: string;
LEN: string;
ATIME: string;
MTIME: string;
PREFIX: string;
BUFFER: string;
OFFSET: string;
LENGTH: string;
POSITION: string;
};
export declare enum FLAGS {
r,
'r+',
rs,
sr,
'rs+',
'sr+',
w,
wx,
xw,
'w+',
'wx+',
'xw+',
a,
ax,
xa,
'a+',
'ax+',
'xa+'
}
+57
View File
@@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FLAGS = exports.ERRSTR = void 0;
const constants_1 = require("../constants");
exports.ERRSTR = {
PATH_STR: 'path must be a string, Buffer, or Uint8Array',
// FD: 'file descriptor must be a unsigned 32-bit integer',
FD: 'fd must be a file descriptor',
MODE_INT: 'mode must be an int',
CB: 'callback must be a function',
UID: 'uid must be an unsigned int',
GID: 'gid must be an unsigned int',
LEN: 'len must be an integer',
ATIME: 'atime must be an integer',
MTIME: 'mtime must be an integer',
PREFIX: 'filename prefix is required',
BUFFER: 'buffer must be an instance of Buffer or StaticBuffer',
OFFSET: 'offset must be an integer',
LENGTH: 'length must be an integer',
POSITION: 'position must be an integer',
};
const { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_SYNC } = constants_1.constants;
// List of file `flags` as defined by Node.
var FLAGS;
(function (FLAGS) {
// Open file for reading. An exception occurs if the file does not exist.
FLAGS[FLAGS["r"] = O_RDONLY] = "r";
// Open file for reading and writing. An exception occurs if the file does not exist.
FLAGS[FLAGS["r+"] = O_RDWR] = "r+";
// Open file for reading in synchronous mode. Instructs the operating system to bypass the local file system cache.
FLAGS[FLAGS["rs"] = O_RDONLY | O_SYNC] = "rs";
FLAGS[FLAGS["sr"] = FLAGS.rs] = "sr";
// Open file for reading and writing, telling the OS to open it synchronously. See notes for 'rs' about using this with caution.
FLAGS[FLAGS["rs+"] = O_RDWR | O_SYNC] = "rs+";
FLAGS[FLAGS["sr+"] = FLAGS['rs+']] = "sr+";
// Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
FLAGS[FLAGS["w"] = O_WRONLY | O_CREAT | O_TRUNC] = "w";
// Like 'w' but fails if path exists.
FLAGS[FLAGS["wx"] = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL] = "wx";
FLAGS[FLAGS["xw"] = FLAGS.wx] = "xw";
// Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
FLAGS[FLAGS["w+"] = O_RDWR | O_CREAT | O_TRUNC] = "w+";
// Like 'w+' but fails if path exists.
FLAGS[FLAGS["wx+"] = O_RDWR | O_CREAT | O_TRUNC | O_EXCL] = "wx+";
FLAGS[FLAGS["xw+"] = FLAGS['wx+']] = "xw+";
// Open file for appending. The file is created if it does not exist.
FLAGS[FLAGS["a"] = O_WRONLY | O_APPEND | O_CREAT] = "a";
// Like 'a' but fails if path exists.
FLAGS[FLAGS["ax"] = O_WRONLY | O_APPEND | O_CREAT | O_EXCL] = "ax";
FLAGS[FLAGS["xa"] = FLAGS.ax] = "xa";
// Open file for reading and appending. The file is created if it does not exist.
FLAGS[FLAGS["a+"] = O_RDWR | O_APPEND | O_CREAT] = "a+";
// Like 'a+' but fails if path exists.
FLAGS[FLAGS["ax+"] = O_RDWR | O_APPEND | O_CREAT | O_EXCL] = "ax+";
FLAGS[FLAGS["xa+"] = FLAGS['ax+']] = "xa+";
})(FLAGS || (exports.FLAGS = FLAGS = {}));
//# sourceMappingURL=constants.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/node/constants.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAS5B,QAAA,MAAM,GAAG;IACpB,QAAQ,EAAE,8CAA8C;IACxD,uEAAuE;IACvE,EAAE,EAAE,8BAA8B;IAClC,QAAQ,EAAE,qBAAqB;IAC/B,EAAE,EAAE,6BAA6B;IACjC,GAAG,EAAE,6BAA6B;IAClC,GAAG,EAAE,6BAA6B;IAClC,GAAG,EAAE,wBAAwB;IAC7B,KAAK,EAAE,0BAA0B;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,oBAAK,KAAK,CAAC,EAAE,QAAA,CAAA;IACb,iFAAiF;IACjF,oBAAO,MAAM,GAAG,QAAQ,GAAG,OAAO,QAAA,CAAA;IAClC,sCAAsC;IACtC,qBAAQ,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,SAAA,CAAA;IAC5C,qBAAQ,KAAK,CAAC,KAAK,CAAC,SAAA,CAAA;AACtB,CAAC,EA/BW,KAAK,qBAAL,KAAK,QA+BhB"}
+2
View File
@@ -0,0 +1,2 @@
import type { FsCallbackApi } from '../types';
export declare const fsCallbackApiList: Array<keyof FsCallbackApi>;
+50
View File
@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fsCallbackApiList = void 0;
exports.fsCallbackApiList = [
'access',
'appendFile',
'chmod',
'chown',
'close',
'copyFile',
'createReadStream',
'createWriteStream',
'exists',
'fchmod',
'fchown',
'fdatasync',
'fstat',
'fsync',
'ftruncate',
'futimes',
'lchmod',
'lchown',
'link',
'lstat',
'mkdir',
'mkdtemp',
'open',
'read',
'readv',
'readdir',
'readFile',
'readlink',
'realpath',
'rename',
'rm',
'rmdir',
'stat',
'symlink',
'truncate',
'unlink',
'unwatchFile',
'utimes',
'lutimes',
'watch',
'watchFile',
'write',
'writev',
'writeFile',
];
//# sourceMappingURL=fsCallbackApiList.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fsCallbackApiList.js","sourceRoot":"","sources":["../../../src/node/lists/fsCallbackApiList.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAA+B;IAC3D,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,kBAAkB;IAClB,mBAAmB;IACnB,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,OAAO;IACP,OAAO;IACP,WAAW;IACX,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,MAAM;IACN,SAAS;IACT,UAAU;IACV,QAAQ;IACR,aAAa;IACb,QAAQ;IACR,SAAS;IACT,OAAO;IACP,WAAW;IACX,OAAO;IACP,QAAQ;IACR,WAAW;CACZ,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
import type { FsCommonObjects } from '../types/FsCommonObjects';
export declare const fsCommonObjectsList: Array<keyof FsCommonObjects>;
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fsCommonObjectsList = void 0;
exports.fsCommonObjectsList = [
'F_OK',
'R_OK',
'W_OK',
'X_OK',
'constants',
'Stats',
'StatFs',
'Dir',
'Dirent',
'StatsWatcher',
'FSWatcher',
'ReadStream',
'WriteStream',
];
//# sourceMappingURL=fsCommonObjectsList.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fsCommonObjectsList.js","sourceRoot":"","sources":["../../../src/node/lists/fsCommonObjectsList.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAiC;IAC/D,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;IACP,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,cAAc;IACd,WAAW;IACX,YAAY;IACZ,aAAa;CACd,CAAC"}
+2
View File
@@ -0,0 +1,2 @@
import type { FsSynchronousApi } from '../types';
export declare const fsSynchronousApiList: Array<keyof FsSynchronousApi>;
+47
View File
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fsSynchronousApiList = void 0;
exports.fsSynchronousApiList = [
'accessSync',
'appendFileSync',
'chmodSync',
'chownSync',
'closeSync',
'copyFileSync',
'existsSync',
'fchmodSync',
'fchownSync',
'fdatasyncSync',
'fstatSync',
'fsyncSync',
'ftruncateSync',
'futimesSync',
'lchmodSync',
'lchownSync',
'linkSync',
'lstatSync',
'mkdirSync',
'mkdtempSync',
'openSync',
'readdirSync',
'readFileSync',
'readlinkSync',
'readSync',
'readvSync',
'realpathSync',
'renameSync',
'rmdirSync',
'rmSync',
'statSync',
'symlinkSync',
'truncateSync',
'unlinkSync',
'utimesSync',
'lutimesSync',
'writeFileSync',
'writeSync',
'writevSync',
// 'cpSync',
// 'statfsSync',
];
//# sourceMappingURL=fsSynchronousApiList.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fsSynchronousApiList.js","sourceRoot":"","sources":["../../../src/node/lists/fsSynchronousApiList.ts"],"names":[],"mappings":";;;AAEa,QAAA,oBAAoB,GAAkC;IACjE,YAAY;IACZ,gBAAgB;IAChB,WAAW;IACX,WAAW;IACX,WAAW;IACX,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,WAAW;IACX,WAAW;IACX,eAAe;IACf,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,aAAa;IACb,UAAU;IACV,aAAa;IACb,cAAc;IACd,cAAc;IACd,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,UAAU;IACV,aAAa;IACb,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,eAAe;IACf,WAAW;IACX,YAAY;IAEZ,YAAY;IACZ,gBAAgB;CACjB,CAAC"}
+25
View File
@@ -0,0 +1,25 @@
import type * as opts from './types/options';
import * as misc from './types/misc';
import { IAppendFileOptions } from '../volume';
export declare const getMkdirOptions: (options: any) => opts.IMkdirOptions;
export declare function getOptions<T extends opts.IOptions>(defaults: T, options?: T | string): T;
export declare function optsGenerator<TOpts>(defaults: TOpts): (opts: any) => TOpts;
export declare function optsAndCbGenerator<TOpts, TResult>(getOpts: any): (options: any, callback?: any) => [TOpts, misc.TCallback<TResult>];
export declare const optsDefaults: opts.IOptions;
export declare const getDefaultOpts: (opts: any) => opts.IOptions;
export declare const getDefaultOptsAndCb: (options: any, callback?: any) => [opts.IOptions, misc.TCallback<any>];
export declare const getRmdirOptions: (options: any) => opts.IRmdirOptions;
export declare const getRmOptsAndCb: (options: any, callback?: any) => [opts.IRmOptions, misc.TCallback<any>];
export declare const getReadFileOptions: (opts: any) => opts.IReadFileOptions;
export declare const getReaddirOptions: (opts: any) => opts.IReaddirOptions;
export declare const getReaddirOptsAndCb: (options: any, callback?: any) => [opts.IReaddirOptions, misc.TCallback<misc.TDataOut[] | misc.IDirent[]>];
export declare const getOpendirOptions: (opts: any) => opts.IOpendirOptions;
export declare const getOpendirOptsAndCb: (options: any, callback?: any) => [opts.IOpendirOptions, misc.TCallback<misc.IDir>];
export declare const getAppendFileOpts: (opts: any) => IAppendFileOptions;
export declare const getAppendFileOptsAndCb: (options: any, callback?: any) => [IAppendFileOptions, misc.TCallback<void>];
export declare const getStatOptions: (options?: any) => opts.IStatOptions;
export declare const getStatOptsAndCb: (options: any, callback?: misc.TCallback<misc.IStats>) => [opts.IStatOptions, misc.TCallback<misc.IStats>];
export declare const getRealpathOptions: (opts: any) => opts.IRealpathOptions;
export declare const getRealpathOptsAndCb: (options: any, callback?: any) => [opts.IRealpathOptions, misc.TCallback<misc.TDataOut>];
export declare const writeFileDefaults: opts.IWriteFileOptions;
export declare const getWriteFileOptions: (opts: any) => opts.IWriteFileOptions;
+103
View File
@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWriteFileOptions = exports.writeFileDefaults = exports.getRealpathOptsAndCb = exports.getRealpathOptions = exports.getStatOptsAndCb = exports.getStatOptions = exports.getAppendFileOptsAndCb = exports.getAppendFileOpts = exports.getOpendirOptsAndCb = exports.getOpendirOptions = exports.getReaddirOptsAndCb = exports.getReaddirOptions = exports.getReadFileOptions = exports.getRmOptsAndCb = exports.getRmdirOptions = exports.getDefaultOptsAndCb = exports.getDefaultOpts = exports.optsDefaults = exports.getMkdirOptions = void 0;
exports.getOptions = getOptions;
exports.optsGenerator = optsGenerator;
exports.optsAndCbGenerator = optsAndCbGenerator;
const constants_1 = require("./constants");
const encoding_1 = require("../encoding");
const util_1 = require("./util");
const mkdirDefaults = {
mode: 511 /* MODE.DIR */,
recursive: false,
};
const getMkdirOptions = (options) => {
if (typeof options === 'number')
return Object.assign({}, mkdirDefaults, { mode: options });
return Object.assign({}, mkdirDefaults, options);
};
exports.getMkdirOptions = getMkdirOptions;
const ERRSTR_OPTS = tipeof => `Expected options to be either an object or a string, but got ${tipeof} instead`;
function getOptions(defaults, options) {
let opts;
if (!options)
return defaults;
else {
const tipeof = typeof options;
switch (tipeof) {
case 'string':
opts = Object.assign({}, defaults, { encoding: options });
break;
case 'object':
opts = Object.assign({}, defaults, options);
break;
default:
throw TypeError(ERRSTR_OPTS(tipeof));
}
}
if (opts.encoding !== 'buffer')
(0, encoding_1.assertEncoding)(opts.encoding);
return opts;
}
function optsGenerator(defaults) {
return options => getOptions(defaults, options);
}
function optsAndCbGenerator(getOpts) {
return (options, callback) => typeof options === 'function' ? [getOpts(), options] : [getOpts(options), (0, util_1.validateCallback)(callback)];
}
exports.optsDefaults = {
encoding: 'utf8',
};
exports.getDefaultOpts = optsGenerator(exports.optsDefaults);
exports.getDefaultOptsAndCb = optsAndCbGenerator(exports.getDefaultOpts);
const rmdirDefaults = {
recursive: false,
};
const getRmdirOptions = (options) => {
return Object.assign({}, rmdirDefaults, options);
};
exports.getRmdirOptions = getRmdirOptions;
const getRmOpts = optsGenerator(exports.optsDefaults);
exports.getRmOptsAndCb = optsAndCbGenerator(getRmOpts);
const readFileOptsDefaults = {
flag: 'r',
};
exports.getReadFileOptions = optsGenerator(readFileOptsDefaults);
const readdirDefaults = {
encoding: 'utf8',
recursive: false,
withFileTypes: false,
};
exports.getReaddirOptions = optsGenerator(readdirDefaults);
exports.getReaddirOptsAndCb = optsAndCbGenerator(exports.getReaddirOptions);
const opendirDefaults = {
encoding: 'utf8',
bufferSize: 32,
recursive: false,
};
exports.getOpendirOptions = optsGenerator(opendirDefaults);
exports.getOpendirOptsAndCb = optsAndCbGenerator(exports.getOpendirOptions);
const appendFileDefaults = {
encoding: 'utf8',
mode: 438 /* MODE.DEFAULT */,
flag: constants_1.FLAGS[constants_1.FLAGS.a],
};
exports.getAppendFileOpts = optsGenerator(appendFileDefaults);
exports.getAppendFileOptsAndCb = optsAndCbGenerator(exports.getAppendFileOpts);
const statDefaults = {
bigint: false,
};
const getStatOptions = (options = {}) => Object.assign({}, statDefaults, options);
exports.getStatOptions = getStatOptions;
const getStatOptsAndCb = (options, callback) => typeof options === 'function' ? [(0, exports.getStatOptions)(), options] : [(0, exports.getStatOptions)(options), (0, util_1.validateCallback)(callback)];
exports.getStatOptsAndCb = getStatOptsAndCb;
const realpathDefaults = exports.optsDefaults;
exports.getRealpathOptions = optsGenerator(realpathDefaults);
exports.getRealpathOptsAndCb = optsAndCbGenerator(exports.getRealpathOptions);
exports.writeFileDefaults = {
encoding: 'utf8',
mode: 438 /* MODE.DEFAULT */,
flag: constants_1.FLAGS[constants_1.FLAGS.w],
};
exports.getWriteFileOptions = optsGenerator(exports.writeFileDefaults);
//# sourceMappingURL=options.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/node/options.ts"],"names":[],"mappings":";;;AAmBA,gCAoBC;AAED,sCAEC;AAED,gDAGC;AA/CD,2CAA0C;AAC1C,0CAA6C;AAE7C,iCAA0C;AAG1C,MAAM,aAAa,GAAuB;IACxC,IAAI,oBAAU;IACd,SAAS,EAAE,KAAK;CACjB,CAAC;AAEK,MAAM,eAAe,GAAG,CAAC,OAAO,EAAsB,EAAE;IAC7D,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5F,OAAO,MAAM,CAAC,MAA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EAAE,iBAAK,CAAC,iBAAK,CAAC,CAAC,CAAC;CACrB,CAAC;AACW,QAAA,iBAAiB,GAAG,aAAa,CAAqB,kBAAkB,CAAC,CAAC;AAC1E,QAAA,sBAAsB,GAAG,kBAAkB,CAA2B,yBAAiB,CAAC,CAAC;AAEtG,MAAM,YAAY,GAAsB;IACtC,MAAM,EAAE,KAAK;CACd,CAAC;AACK,MAAM,cAAc,GAAyC,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CACnF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAD9B,QAAA,cAAc,kBACgB;AACpC,MAAM,gBAAgB,GAG2B,CAAC,OAAO,EAAE,QAAS,EAAE,EAAE,CAC7E,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAc,GAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,OAAO,CAAC,EAAE,IAAA,uBAAgB,EAAC,QAAQ,CAAC,CAAC,CAAC;AAJzG,QAAA,gBAAgB,oBAIyF;AAEtH,MAAM,gBAAgB,GAA0B,oBAAY,CAAC;AAChD,QAAA,kBAAkB,GAAG,aAAa,CAAwB,gBAAgB,CAAC,CAAC;AAC5E,QAAA,oBAAoB,GAAG,kBAAkB,CAAuC,0BAAkB,CAAC,CAAC;AAEpG,QAAA,iBAAiB,GAA2B;IACvD,QAAQ,EAAE,MAAM;IAChB,IAAI,wBAAc;IAClB,IAAI,EAAE,iBAAK,CAAC,iBAAK,CAAC,CAAC,CAAC;CACrB,CAAC;AACW,QAAA,mBAAmB,GAAG,aAAa,CAAyB,yBAAiB,CAAC,CAAC"}
+89
View File
@@ -0,0 +1,89 @@
import type * as misc from './misc';
import type * as opts from './options';
export interface FsCallbackApi {
access(path: misc.PathLike, callback: misc.TCallback<void>): any;
access(path: misc.PathLike, mode: number, callback: misc.TCallback<void>): any;
appendFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): any;
appendFile(id: misc.TFileId, data: misc.TData, options: opts.IAppendFileOptions | string, callback: misc.TCallback<void>): any;
chmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
chown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
close(fd: number, callback: misc.TCallback<void>): void;
copyFile(src: misc.PathLike, dest: misc.PathLike, callback: misc.TCallback<void>): any;
copyFile(src: misc.PathLike, dest: misc.PathLike, flags: misc.TFlagsCopy, callback: misc.TCallback<void>): any;
cp(src: string | URL, dest: string | URL, callback: misc.TCallback<void>): any;
cp(src: string | URL, dest: string | URL, options: opts.ICpOptions, callback: misc.TCallback<void>): any;
createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream;
createWriteStream(path: misc.PathLike, options?: opts.IWriteStreamOptions | string): misc.IWriteStream;
exists(path: misc.PathLike, callback: (exists: boolean) => void): void;
fchmod(fd: number, mode: misc.TMode, callback: misc.TCallback<void>): void;
fchown(fd: number, uid: number, gid: number, callback: misc.TCallback<void>): void;
fdatasync(fd: number, callback: misc.TCallback<void>): void;
fsync(fd: number, callback: misc.TCallback<void>): void;
fstat(fd: number, callback: misc.TCallback<misc.IStats>): void;
fstat(fd: number, options: opts.IFStatOptions, callback: misc.TCallback<misc.IStats>): void;
ftruncate(fd: number, callback: misc.TCallback<void>): any;
ftruncate(fd: number, len: number, callback: misc.TCallback<void>): any;
futimes(fd: number, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
lchmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void;
lchown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void;
lutimes(path: misc.PathLike, atime: number | string | Date, mtime: number | string | Date, callback: misc.TCallback<void>): void;
link(existingPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
lstat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
lstat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
mkdir(path: misc.PathLike, callback: misc.TCallback<void>): any;
mkdir(path: misc.PathLike, mode: misc.TMode | (opts.IMkdirOptions & {
recursive?: false;
}), callback: misc.TCallback<void>): any;
mkdir(path: misc.PathLike, mode: opts.IMkdirOptions & {
recursive: true;
}, callback: misc.TCallback<string>): any;
mkdir(path: misc.PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>): any;
mkdtemp(prefix: string, callback: misc.TCallback<string>): void;
mkdtemp(prefix: string, options: opts.IOptions, callback: misc.TCallback<string>): any;
open(path: misc.PathLike, flags: misc.TFlags, callback: misc.TCallback<number>): any;
open(path: misc.PathLike, flags: misc.TFlags, mode: misc.TMode, callback: misc.TCallback<number>): any;
openAsBlob(path: misc.PathLike, options?: opts.IOpenAsBlobOptions): Promise<Blob>;
opendir(path: misc.PathLike, options: opts.IOpendirOptions, callback: misc.TCallback<misc.IDir>): void;
read(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number, callback: (err?: Error | null, bytesRead?: number, buffer?: Buffer | ArrayBufferView | DataView) => void): void;
readdir(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
readdir(path: misc.PathLike, options: opts.IReaddirOptions | string, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>): any;
readFile(id: misc.TFileId, callback: misc.TCallback<misc.TDataOut>): any;
readFile(id: misc.TFileId, options: opts.IReadFileOptions | string, callback: misc.TCallback<misc.TDataOut>): any;
readlink(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): any;
readlink(path: misc.PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>): any;
readv(fd: number, buffers: ArrayBufferView[], callback: misc.TCallback2<number, ArrayBufferView[]>): void;
readv(fd: number, buffers: ArrayBufferView[], position: number | null, callback: misc.TCallback2<number, ArrayBufferView[]>): void;
realpath(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>): any;
realpath(path: misc.PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>): any;
rename(oldPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void;
rmdir(path: misc.PathLike, callback: misc.TCallback<void>): any;
rmdir(path: misc.PathLike, options: opts.IRmdirOptions, callback: misc.TCallback<void>): any;
rm(path: misc.PathLike, callback: misc.TCallback<void>): void;
rm(path: misc.PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void;
stat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void;
stat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void;
statfs(path: misc.PathLike, callback: misc.TCallback<misc.IStatFs>): void;
statfs(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStatFs>): void;
symlink(target: misc.PathLike, path: misc.PathLike, callback: misc.TCallback<void>): any;
symlink(target: misc.PathLike, path: misc.PathLike, type: misc.symlink.Type, callback: misc.TCallback<void>): any;
truncate(id: misc.PathLike, callback: misc.TCallback<void>): any;
truncate(id: misc.PathLike, len: number, callback: misc.TCallback<void>): any;
unlink(path: misc.PathLike, callback: misc.TCallback<void>): void;
unwatchFile(path: misc.PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void): void;
utimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void;
watch(path: misc.PathLike, options?: opts.IWatchOptions | string, listener?: (eventType: string, filename: string) => void): misc.IFSWatcher;
watchFile(path: misc.PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
watchFile(path: misc.PathLike, options: opts.IWatchFileOptions, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher;
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, callback: (...args: any[]) => void): any;
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, callback: (...args: any[]) => void): any;
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, callback: (...args: any[]) => void): any;
write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number, callback: (...args: any[]) => void): any;
write(fd: number, str: string, callback: (...args: any[]) => void): any;
write(fd: number, str: string, position: number, callback: (...args: any[]) => void): any;
write(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args: any[]) => void): any;
writeFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>): any;
writeFile(id: misc.TFileId, data: misc.TData, options: opts.IWriteFileOptions | string, callback: misc.TCallback<void>): any;
writev(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void;
writev(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void;
}
export type WritevCallback = (err: Error | null, bytesWritten?: number, buffers?: ArrayBufferView[]) => void;
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=FsCallbackApi.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FsCallbackApi.js","sourceRoot":"","sources":["../../../src/node/types/FsCallbackApi.ts"],"names":[],"mappings":""}
+17
View File
@@ -0,0 +1,17 @@
import type { constants } from '../../constants';
import type * as misc from './misc';
export interface FsCommonObjects {
F_OK: number;
R_OK: number;
W_OK: number;
X_OK: number;
constants: typeof constants;
Dir: new (...args: unknown[]) => misc.IDir;
Dirent: new (...args: unknown[]) => misc.IDirent;
FSWatcher: new (...args: unknown[]) => misc.IFSWatcher;
ReadStream: new (...args: unknown[]) => misc.IReadStream;
StatFs: new (...args: unknown[]) => misc.IStatFs;
Stats: new (...args: unknown[]) => misc.IStats;
StatsWatcher: new (...args: unknown[]) => misc.IStatWatcher;
WriteStream: new (...args: unknown[]) => misc.IWriteStream;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=FsCommonObjects.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FsCommonObjects.js","sourceRoot":"","sources":["../../../src/node/types/FsCommonObjects.ts"],"names":[],"mappings":""}
+40
View File
@@ -0,0 +1,40 @@
import type { constants } from '../../constants';
import * as misc from './misc';
import * as opts from './options';
export interface FsPromisesApi {
constants: typeof constants;
FileHandle: new (...args: unknown[]) => misc.IFileHandle;
access(path: misc.PathLike, mode?: number): Promise<void>;
appendFile(path: misc.TFileHandle, data: misc.TData, options?: opts.IAppendFileOptions | string): Promise<void>;
chmod(path: misc.PathLike, mode: misc.TMode): Promise<void>;
chown(path: misc.PathLike, uid: number, gid: number): Promise<void>;
copyFile(src: misc.PathLike, dest: misc.PathLike, flags?: misc.TFlagsCopy): Promise<void>;
cp(src: string | URL, dest: string | URL, options?: opts.ICpOptions): Promise<void>;
lchmod(path: misc.PathLike, mode: misc.TMode): Promise<void>;
lchown(path: misc.PathLike, uid: number, gid: number): Promise<void>;
lutimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime): Promise<void>;
link(existingPath: misc.PathLike, newPath: misc.PathLike): Promise<void>;
lstat(path: misc.PathLike, options?: opts.IStatOptions): Promise<misc.IStats>;
mkdir(path: misc.PathLike, options?: misc.TMode | opts.IMkdirOptions): Promise<string | undefined>;
mkdtemp(prefix: string, options?: opts.IOptions): Promise<misc.TDataOut>;
open(path: misc.PathLike, flags?: misc.TFlags, mode?: misc.TMode): Promise<misc.IFileHandle>;
opendir(path: misc.PathLike, options?: opts.IOpendirOptions): Promise<misc.IDir>;
readdir(path: misc.PathLike, options?: opts.IReaddirOptions | string): Promise<misc.TDataOut[] | misc.IDirent[]>;
readFile(id: misc.TFileHandle, options?: opts.IReadFileOptions | string): Promise<misc.TDataOut>;
readlink(path: misc.PathLike, options?: opts.IOptions): Promise<misc.TDataOut>;
realpath(path: misc.PathLike, options?: opts.IRealpathOptions | string): Promise<misc.TDataOut>;
rename(oldPath: misc.PathLike, newPath: misc.PathLike): Promise<void>;
rmdir(path: misc.PathLike, options?: opts.IRmdirOptions): Promise<void>;
rm(path: misc.PathLike, options?: opts.IRmOptions): Promise<void>;
stat(path: misc.PathLike, options?: opts.IStatOptions): Promise<misc.IStats>;
statfs(path: misc.PathLike, options?: opts.IStatOptions): Promise<misc.IStatFs>;
symlink(target: misc.PathLike, path: misc.PathLike, type?: misc.symlink.Type): Promise<void>;
truncate(path: misc.PathLike, len?: number): Promise<void>;
unlink(path: misc.PathLike): Promise<void>;
utimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime): Promise<void>;
watch(filename: misc.PathLike, options?: opts.IWatchOptions): AsyncIterableIterator<{
eventType: string;
filename: string | Buffer;
}>;
writeFile(id: misc.TFileHandle, data: misc.TPromisesData, options?: opts.IWriteFileOptions): Promise<void>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=FsPromisesApi.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FsPromisesApi.js","sourceRoot":"","sources":["../../../src/node/types/FsPromisesApi.ts"],"names":[],"mappings":""}
+103
View File
@@ -0,0 +1,103 @@
import type * as misc from './misc';
import type * as opts from './options';
export interface FsSynchronousApi {
accessSync(path: misc.PathLike, mode?: number): void;
appendFileSync(id: misc.TFileId, data: misc.TData, options?: opts.IAppendFileOptions | string): void;
chmodSync(path: misc.PathLike, mode: misc.TMode): void;
chownSync(path: misc.PathLike, uid: number, gid: number): void;
closeSync(fd: number): void;
copyFileSync(src: misc.PathLike, dest: misc.PathLike, flags?: misc.TFlagsCopy): void;
cpSync(src: string | URL, dest: string | URL, options?: opts.ICpOptions): void;
existsSync(path: misc.PathLike): boolean;
fchmodSync(fd: number, mode: misc.TMode): void;
fchownSync(fd: number, uid: number, gid: number): void;
fdatasyncSync(fd: number): void;
fstatSync(fd: number, options: {
bigint: false;
}): misc.IStats<number>;
fstatSync(fd: number, options: {
bigint: true;
}): misc.IStats<bigint>;
fstatSync(fd: number): misc.IStats<number>;
fsyncSync(fd: number): void;
ftruncateSync(fd: number, len?: number): void;
futimesSync(fd: number, atime: misc.TTime, mtime: misc.TTime): void;
lchmodSync(path: misc.PathLike, mode: misc.TMode): void;
lchownSync(path: misc.PathLike, uid: number, gid: number): void;
lutimesSync(path: misc.PathLike, atime: number | string | Date, time: number | string | Date): void;
linkSync(existingPath: misc.PathLike, newPath: misc.PathLike): void;
lstatSync(path: misc.PathLike, options: {
bigint: false;
throwIfNoEntry: false;
}): misc.IStats<number> | undefined;
lstatSync(path: misc.PathLike, options: {
bigint: false;
throwIfNoEntry?: true | undefined;
}): misc.IStats<number>;
lstatSync(path: misc.PathLike, options: {
bigint: true;
throwIfNoEntry: false;
}): misc.IStats<bigint> | undefined;
lstatSync(path: misc.PathLike, options: {
bigint: true;
throwIfNoEntry?: true | undefined;
}): misc.IStats<bigint>;
lstatSync(path: misc.PathLike, options: {
throwIfNoEntry: false;
}): misc.IStats<number> | undefined;
lstatSync(path: misc.PathLike, options: {
throwIfNoEntry?: true | undefined;
}): misc.IStats<number>;
lstatSync(path: misc.PathLike): misc.IStats<number>;
mkdirSync(path: misc.PathLike, options: opts.IMkdirOptions & {
recursive: true;
}): string | undefined;
mkdirSync(path: misc.PathLike, options?: misc.TMode | (opts.IMkdirOptions & {
recursive?: false;
})): void;
mkdirSync(path: misc.PathLike, options?: misc.TMode | opts.IMkdirOptions): string | undefined;
mkdtempSync(prefix: string, options?: opts.IOptions): misc.TDataOut;
openSync(path: misc.PathLike, flags: misc.TFlags, mode?: misc.TMode): number;
opendirSync(path: misc.PathLike, options?: opts.IOpendirOptions): misc.IDir;
readdirSync(path: misc.PathLike, options?: opts.IReaddirOptions | string): misc.TDataOut[] | misc.IDirent[];
readlinkSync(path: misc.PathLike, options?: opts.IOptions): misc.TDataOut;
readSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number): number;
readFileSync(file: misc.TFileId, options?: opts.IReadFileOptions | string): misc.TDataOut;
readvSync(fd: number, buffers: ArrayBufferView[], position?: number | null): number;
realpathSync(path: misc.PathLike, options?: opts.IRealpathOptions | string): misc.TDataOut;
renameSync(oldPath: misc.PathLike, newPath: misc.PathLike): void;
rmdirSync(path: misc.PathLike, options?: opts.IRmdirOptions): void;
rmSync(path: misc.PathLike, options?: opts.IRmOptions): void;
statSync(path: misc.PathLike, options: {
bigint: false;
throwIfNoEntry: false;
}): misc.IStats<number> | undefined;
statSync(path: misc.PathLike, options: {
bigint: false;
throwIfNoEntry?: true;
}): misc.IStats<number>;
statSync(path: misc.PathLike, options: {
bigint: true;
throwIfNoEntry: false;
}): misc.IStats<bigint> | undefined;
statSync(path: misc.PathLike, options: {
bigint: true;
throwIfNoEntry?: true;
}): misc.IStats<bigint>;
statSync(path: misc.PathLike, options: {
throwIfNoEntry: false;
}): misc.IStats<number> | undefined;
statSync(path: misc.PathLike, options: {
throwIfNoEntry?: true;
}): misc.IStats<number>;
statSync(path: misc.PathLike): misc.IStats<number>;
statfsSync(path: misc.PathLike, options?: opts.IStafsOptions): misc.IStatFs;
symlinkSync(target: misc.PathLike, path: misc.PathLike, type?: misc.symlink.Type): void;
truncateSync(id: misc.TFileId, len?: number): void;
unlinkSync(path: misc.PathLike): void;
utimesSync(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime): void;
writeFileSync(id: misc.TFileId, data: misc.TData, options?: opts.IWriteFileOptions): void;
writeSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number | null): number;
writeSync(fd: number, str: string, position?: number, encoding?: BufferEncoding): number;
writevSync(fd: number, buffers: ArrayBufferView[], position?: number | null): void;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=FsSynchronousApi.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FsSynchronousApi.js","sourceRoot":"","sources":["../../../src/node/types/FsSynchronousApi.ts"],"names":[],"mappings":""}
+7
View File
@@ -0,0 +1,7 @@
import type { FsSynchronousApi } from './FsSynchronousApi';
import type { FsCallbackApi } from './FsCallbackApi';
import type { FsPromisesApi } from './FsPromisesApi';
export { FsSynchronousApi, FsCallbackApi, FsPromisesApi };
export interface FsApi extends FsCallbackApi, FsSynchronousApi {
promises: FsPromisesApi;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/types/index.ts"],"names":[],"mappings":""}
+150
View File
@@ -0,0 +1,150 @@
import type { PathLike as NodePathLike, symlink } from 'fs';
import type { constants } from '../../constants';
import type { EventEmitter } from 'events';
import type { TSetTimeout } from '../../setTimeoutUnref';
import type { IAppendFileOptions, IFileHandleReadStreamOptions, IFileHandleWriteStreamOptions, IReadableWebStreamOptions, IReadFileOptions, IStatOptions, IWriteFileOptions } from './options';
import type { Readable, Writable } from 'stream';
export { symlink };
export type PathLike = NodePathLike | Uint8Array;
export type TDataOut = string | Buffer;
export type TEncodingExtended = BufferEncoding | 'buffer';
export type TFileId = PathLike | number;
export type TData = TDataOut | ArrayBufferView | DataView;
export type TPromisesData = TData | Readable;
export type TFlags = string | number;
export type TMode = string | number;
export type TTime = number | string | Date;
export type TCallback<TData> = (error?: IError | null, data?: TData) => void;
export type TCallback2<T1, T2> = (error: IError | null, bytesRead?: T1, buffers?: T2) => void;
export interface IError extends Error {
code?: string;
}
export type TFlagsCopy = typeof constants.COPYFILE_EXCL | typeof constants.COPYFILE_FICLONE | typeof constants.COPYFILE_FICLONE_FORCE;
export type TStatNumber = number | bigint;
export interface IStats<T = TStatNumber> {
uid: T;
gid: T;
rdev: T;
blksize: T;
ino: T;
size: T;
blocks: T;
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
atimeMs: T;
mtimeMs: T;
ctimeMs: T;
birthtimeMs: T;
dev: T;
mode: T;
nlink: T;
isDirectory(): boolean;
isFile(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}
export interface IStatFs<T = TStatNumber> {
bavail: T;
bfree: T;
blocks: T;
bsize: T;
ffree: T;
files: T;
type: T;
}
export interface IDir {
path: string;
close(): Promise<void>;
close(callback?: (err?: Error) => void): void;
closeSync(): void;
read(): Promise<IDirent | null>;
read(callback?: (err: Error | null, dir?: IDirent | null) => void): void;
readSync(): IDirent | null;
[Symbol.asyncIterator](): AsyncIterableIterator<IDirent>;
}
export interface IDirent {
name: TDataOut;
isDirectory(): boolean;
isFile(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}
export interface IStatWatcher extends EventEmitter {
filename: string;
interval: number;
timeoutRef?: any;
setTimeout: TSetTimeout;
prev: IStats;
start(path: string, persistent?: boolean, interval?: number): void;
stop(): void;
}
export interface IReadStream extends Readable {
bytesRead: number;
path: string | Buffer;
pending: boolean;
}
export interface IWriteStream extends Writable {
bytesWritten: number;
path: string;
pending: boolean;
close(callback?: (err?: Error) => void): void;
}
export interface IFSWatcher extends EventEmitter {
start(path: PathLike, persistent?: boolean, recursive?: boolean, encoding?: BufferEncoding): void;
close(): void;
}
/**
* Declare ReadableStream in case dom.d.ts is not added to the tsconfig lib causing
* ReadableStream interface is not defined. For developers with dom.d.ts added,
* the ReadableStream interface will be merged correctly.
*/
declare global {
export interface ReadableStream {
}
}
export interface IFileHandle {
fd: number;
appendFile(data: TData, options?: IAppendFileOptions | string): Promise<void>;
chmod(mode: TMode): Promise<void>;
chown(uid: number, gid: number): Promise<void>;
close(): Promise<void>;
createReadStream(options: IFileHandleReadStreamOptions): IReadStream;
createWriteStream(options: IFileHandleWriteStreamOptions): IWriteStream;
datasync(): Promise<void>;
readableWebStream(options?: IReadableWebStreamOptions): ReadableStream;
read(buffer: Buffer | Uint8Array, offset: number, length: number, position: number): Promise<TFileHandleReadResult>;
readv(buffers: ArrayBufferView[], position?: number | null): Promise<TFileHandleReadvResult>;
readFile(options?: IReadFileOptions | string): Promise<TDataOut>;
stat(options?: IStatOptions): Promise<IStats>;
truncate(len?: number): Promise<void>;
utimes(atime: TTime, mtime: TTime): Promise<void>;
write(buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): Promise<TFileHandleWriteResult>;
writev(buffers: ArrayBufferView[], position?: number | null): Promise<TFileHandleWritevResult>;
writeFile(data: TData, options?: IWriteFileOptions): Promise<void>;
}
export type TFileHandle = PathLike | IFileHandle;
export interface TFileHandleReadResult {
bytesRead: number;
buffer: Buffer | Uint8Array;
}
export interface TFileHandleWriteResult {
bytesWritten: number;
buffer: Buffer | Uint8Array;
}
export interface TFileHandleReadvResult {
bytesRead: number;
buffers: ArrayBufferView[];
}
export interface TFileHandleWritevResult {
bytesWritten: number;
buffers: ArrayBufferView[];
}
export type AssertCallback<T> = T extends () => void ? T : never;
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=misc.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../../src/node/types/misc.ts"],"names":[],"mappings":""}
+169
View File
@@ -0,0 +1,169 @@
import type { IFileHandle, TEncodingExtended, TFlags, TMode } from './misc';
export interface IOptions {
encoding?: BufferEncoding | TEncodingExtended;
}
export interface IFileOptions extends IOptions {
mode?: TMode;
flag?: TFlags;
}
export interface IWriteFileOptions extends IFileOptions {
}
export interface IReadFileOptions extends IOptions {
flag?: string;
}
export interface IRealpathOptions {
encoding?: TEncodingExtended;
}
export interface IAppendFileOptions extends IFileOptions {
}
export interface IStatOptions {
bigint?: boolean;
throwIfNoEntry?: boolean;
}
export interface IFStatOptions {
bigint?: boolean;
}
export interface IAppendFileOptions extends IFileOptions {
}
export interface IReadableWebStreamOptions {
type?: 'bytes' | undefined;
}
export interface IFileHandleReadStreamOptions {
encoding?: BufferEncoding;
autoClose?: boolean;
emitClose?: boolean;
start?: number | undefined;
end?: number;
highWaterMark?: number;
flush?: boolean;
signal?: AbortSignal | undefined;
}
export interface IFileHandleWriteStreamOptions {
encoding?: BufferEncoding;
autoClose?: boolean;
emitClose?: boolean;
start?: number;
highWaterMark?: number;
flush?: boolean;
}
export interface IReaddirOptions extends IOptions {
recursive?: boolean;
withFileTypes?: boolean;
}
export interface IMkdirOptions {
mode?: TMode;
recursive?: boolean;
}
export interface IRmdirOptions {
recursive?: boolean;
maxRetries?: number;
retryDelay?: number;
}
export interface IRmOptions {
force?: boolean;
maxRetries?: number;
recursive?: boolean;
retryDelay?: number;
}
export interface IWatchFileOptions {
persistent?: boolean;
interval?: number;
}
export interface IReadStreamOptions extends IOptions {
/** Defaults to `'r'`. */
flags?: TFlags;
/** Defaults to `null`. */
encoding?: BufferEncoding;
/** Defaults to `null`. */
fd?: number | IFileHandle | null;
/** Defaults to 0o666 */
mode?: TMode;
/** Defaults to `true`. */
autoClose?: boolean;
/** Defaults to `true`. */
emitClose?: boolean;
start?: number;
/** Defaults to `Infinity`. */
end?: number;
/** Defaults to `64 * 1024`. */
highWaterMark?: number;
/** Defaults to `null`. */
fs?: object | null;
/** Defaults to `null`. */
signal?: AbortSignal | null;
}
export interface IWriteStreamOptions {
flags?: TFlags;
encoding?: BufferEncoding;
fd?: number | IFileHandle;
mode?: TMode;
autoClose?: boolean;
emitClose?: boolean;
start?: number;
}
export interface IWatchOptions extends IOptions {
/**
* Indicates whether the process should continue to run as long as files are
* being watched. Default: true.
*/
persistent?: boolean;
/**
* Indicates whether all subdirectories should be watched, or only the current
* directory. This applies when a directory is specified, and only on
* supported platforms (See caveats). Default: false.
*/
recursive?: boolean;
/**
* Allows closing the watcher with an {@link AbortSignal}.
*/
signal?: AbortSignal;
}
export interface ICpOptions {
/** dereference symlinks. Default: false. */
dereference?: boolean;
/**
* When force is false, and the destination exists, throw an error.
* Default: false.
*/
errorOnExist?: boolean;
/**
* Function to filter copied files/directories. Return true to copy the item,
* false to ignore it. Default: undefined.
*/
filter?: (src: string, dest: string) => boolean;
/**
* Overwrite existing file or directory. The copy operation will ignore errors
* if you set this to false and the destination exists. Use the errorOnExist
* option to change this behavior. Default: true.
*/
force?: boolean;
/**
* Integer, modifiers for copy operation. Default: 0. See mode flag of
* `fs.copyFileSync()`.
*/
mode: number;
/** When true timestamps from src will be preserved. Default: false. */
preserveTimestamps: boolean;
/** Copy directories recursively Default: false. */
recursive: boolean;
/** When true, path resolution for symlinks will be skipped. Default: false. */
verbatimSymlinks: boolean;
}
export interface IStafsOptions {
/** Whether the numeric values in the returned `StatFs` object should be bigint. */
bigint?: boolean;
}
export interface IOpenAsBlobOptions {
/** An optional mime type for the blob. */
type?: string;
}
export interface IOpendirOptions extends IOptions {
/**
* Number of directory entries that are buffered internally when reading from
* the directory. Higher values lead to better performance but higher memory
* usage. Default: 32.
*/
bufferSize?: number;
/** Default: false. */
recursive?: boolean;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=options.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/node/types/options.ts"],"names":[],"mappings":""}
+23
View File
@@ -0,0 +1,23 @@
import type { FsCallbackApi } from './types';
import type * as misc from './types/misc';
import { TEncodingExtended } from '../encoding';
import { Readable } from 'stream';
export declare const isWin: boolean;
export declare function promisify(fs: FsCallbackApi, fn: string, getResult?: (result: any) => any): (...args: any[]) => Promise<any>;
export declare function validateCallback<T>(callback: T): misc.AssertCallback<T>;
export declare function modeToNumber(mode: misc.TMode | undefined, def?: any): number;
export declare function nullCheck(path: any, callback?: any): boolean;
export declare function pathToFilename(path: misc.PathLike): string;
export declare function createError(errorCode: string, func?: string, path?: string, path2?: string, Constructor?: ErrorConstructor): Error;
export declare function genRndStr6(): string;
export declare function flagsToNumber(flags: misc.TFlags | undefined): number;
export declare function isFd(path: any): boolean;
export declare function validateFd(fd: any): void;
export declare function streamToBuffer(stream: Readable): Promise<Buffer>;
export declare function dataToBuffer(data: misc.TData, encoding?: string): Buffer;
export declare const bufToUint8: (buf: Buffer) => Uint8Array;
export declare const getWriteArgs: (fd: number, a?: unknown, b?: unknown, c?: unknown, d?: unknown, e?: unknown) => [fd: number, dataAsStr: boolean, buf: Buffer, offset: number, length: number, position: number | null, callback: (...args: any) => void];
export declare const getWriteSyncArgs: (fd: number, a: string | Buffer | ArrayBufferView | DataView, b?: number, c?: number | BufferEncoding, d?: number | null) => [fd: number, buf: Buffer, offset: number, length?: number, position?: number | null];
export declare function bufferToEncoding(buffer: Buffer, encoding?: TEncodingExtended): misc.TDataOut;
export declare function isReadableStream(stream: any): stream is Readable;
export declare const unixify: (filepath: string, stripTrailing?: boolean) => string;
+333
View File
@@ -0,0 +1,333 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unixify = exports.getWriteSyncArgs = exports.getWriteArgs = exports.bufToUint8 = exports.isWin = void 0;
exports.promisify = promisify;
exports.validateCallback = validateCallback;
exports.modeToNumber = modeToNumber;
exports.nullCheck = nullCheck;
exports.pathToFilename = pathToFilename;
exports.createError = createError;
exports.genRndStr6 = genRndStr6;
exports.flagsToNumber = flagsToNumber;
exports.isFd = isFd;
exports.validateFd = validateFd;
exports.streamToBuffer = streamToBuffer;
exports.dataToBuffer = dataToBuffer;
exports.bufferToEncoding = bufferToEncoding;
exports.isReadableStream = isReadableStream;
const constants_1 = require("./constants");
const errors = require("../internal/errors");
const buffer_1 = require("../internal/buffer");
const encoding_1 = require("../encoding");
const buffer_2 = require("../internal/buffer");
const queueMicrotask_1 = require("../queueMicrotask");
exports.isWin = process.platform === 'win32';
function promisify(fs, fn, getResult = input => input) {
return (...args) => new Promise((resolve, reject) => {
fs[fn].bind(fs)(...args, (error, result) => {
if (error)
return reject(error);
return resolve(getResult(result));
});
});
}
function validateCallback(callback) {
if (typeof callback !== 'function')
throw TypeError(constants_1.ERRSTR.CB);
return callback;
}
function _modeToNumber(mode, def) {
if (typeof mode === 'number')
return mode;
if (typeof mode === 'string')
return parseInt(mode, 8);
if (def)
return modeToNumber(def);
return undefined;
}
function modeToNumber(mode, def) {
const result = _modeToNumber(mode, def);
if (typeof result !== 'number' || isNaN(result))
throw new TypeError(constants_1.ERRSTR.MODE_INT);
return result;
}
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
const er = new Error('Path must be a string without null bytes');
er.code = 'ENOENT';
if (typeof callback !== 'function')
throw er;
(0, queueMicrotask_1.default)(() => {
callback(er);
});
return false;
}
return true;
}
function getPathFromURLPosix(url) {
if (url.hostname !== '') {
throw new errors.TypeError('ERR_INVALID_FILE_URL_HOST', process.platform);
}
const pathname = url.pathname;
for (let n = 0; n < pathname.length; n++) {
if (pathname[n] === '%') {
const third = pathname.codePointAt(n + 2) | 0x20;
if (pathname[n + 1] === '2' && third === 102) {
throw new errors.TypeError('ERR_INVALID_FILE_URL_PATH', 'must not include encoded / characters');
}
}
}
return decodeURIComponent(pathname);
}
function pathToFilename(path) {
if (path instanceof Uint8Array) {
path = (0, buffer_2.bufferFrom)(path);
}
if (typeof path !== 'string' && !buffer_1.Buffer.isBuffer(path)) {
try {
if (!(path instanceof require('url').URL))
throw new TypeError(constants_1.ERRSTR.PATH_STR);
}
catch (err) {
throw new TypeError(constants_1.ERRSTR.PATH_STR);
}
path = getPathFromURLPosix(path);
}
const pathString = String(path);
nullCheck(pathString);
// return slash(pathString);
return pathString;
}
const ENOENT = 'ENOENT';
const EBADF = 'EBADF';
const EINVAL = 'EINVAL';
const EPERM = 'EPERM';
const EPROTO = 'EPROTO';
const EEXIST = 'EEXIST';
const ENOTDIR = 'ENOTDIR';
const EMFILE = 'EMFILE';
const EACCES = 'EACCES';
const EISDIR = 'EISDIR';
const ENOTEMPTY = 'ENOTEMPTY';
const ENOSYS = 'ENOSYS';
const ERR_FS_EISDIR = 'ERR_FS_EISDIR';
const ERR_OUT_OF_RANGE = 'ERR_OUT_OF_RANGE';
function formatError(errorCode, func = '', path = '', path2 = '') {
let pathFormatted = '';
if (path)
pathFormatted = ` '${path}'`;
if (path2)
pathFormatted += ` -> '${path2}'`;
switch (errorCode) {
case ENOENT:
return `ENOENT: no such file or directory, ${func}${pathFormatted}`;
case EBADF:
return `EBADF: bad file descriptor, ${func}${pathFormatted}`;
case EINVAL:
return `EINVAL: invalid argument, ${func}${pathFormatted}`;
case EPERM:
return `EPERM: operation not permitted, ${func}${pathFormatted}`;
case EPROTO:
return `EPROTO: protocol error, ${func}${pathFormatted}`;
case EEXIST:
return `EEXIST: file already exists, ${func}${pathFormatted}`;
case ENOTDIR:
return `ENOTDIR: not a directory, ${func}${pathFormatted}`;
case EISDIR:
return `EISDIR: illegal operation on a directory, ${func}${pathFormatted}`;
case EACCES:
return `EACCES: permission denied, ${func}${pathFormatted}`;
case ENOTEMPTY:
return `ENOTEMPTY: directory not empty, ${func}${pathFormatted}`;
case EMFILE:
return `EMFILE: too many open files, ${func}${pathFormatted}`;
case ENOSYS:
return `ENOSYS: function not implemented, ${func}${pathFormatted}`;
case ERR_FS_EISDIR:
return `[ERR_FS_EISDIR]: Path is a directory: ${func} returned EISDIR (is a directory) ${path}`;
case ERR_OUT_OF_RANGE:
return `[ERR_OUT_OF_RANGE]: value out of range, ${func}${pathFormatted}`;
default:
return `${errorCode}: error occurred, ${func}${pathFormatted}`;
}
}
function createError(errorCode, func = '', path = '', path2 = '', Constructor = Error) {
const error = new Constructor(formatError(errorCode, func, path, path2));
error.code = errorCode;
if (path) {
error.path = path;
}
return error;
}
function genRndStr6() {
const str = (Math.random() + 1).toString(36).substring(2, 8);
if (str.length === 6)
return str;
else
return genRndStr6();
}
function flagsToNumber(flags) {
if (typeof flags === 'number')
return flags;
if (typeof flags === 'string') {
const flagsNum = constants_1.FLAGS[flags];
if (typeof flagsNum !== 'undefined')
return flagsNum;
}
// throw new TypeError(formatError(ERRSTR_FLAG(flags)));
throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'flags', flags);
}
function isFd(path) {
return path >>> 0 === path;
}
function validateFd(fd) {
if (!isFd(fd))
throw TypeError(constants_1.ERRSTR.FD);
}
function streamToBuffer(stream) {
const chunks = [];
return new Promise((resolve, reject) => {
stream.on('data', chunk => chunks.push(chunk));
stream.on('end', () => resolve(buffer_1.Buffer.concat(chunks)));
stream.on('error', reject);
});
}
function dataToBuffer(data, encoding = encoding_1.ENCODING_UTF8) {
if (buffer_1.Buffer.isBuffer(data))
return data;
else if (data instanceof Uint8Array)
return (0, buffer_2.bufferFrom)(data);
else
return (0, buffer_2.bufferFrom)(String(data), encoding);
}
const bufToUint8 = (buf) => new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
exports.bufToUint8 = bufToUint8;
const getWriteArgs = (fd, a, b, c, d, e) => {
validateFd(fd);
let offset = 0;
let length;
let position = null;
let encoding;
let callback;
const tipa = typeof a;
const tipb = typeof b;
const tipc = typeof c;
const tipd = typeof d;
if (tipa !== 'string') {
if (tipb === 'function') {
callback = b;
}
else if (tipc === 'function') {
offset = b | 0;
callback = c;
}
else if (tipd === 'function') {
offset = b | 0;
length = c;
callback = d;
}
else {
offset = b | 0;
length = c;
position = d;
callback = e;
}
}
else {
if (tipb === 'function') {
callback = b;
}
else if (tipc === 'function') {
position = b;
callback = c;
}
else if (tipd === 'function') {
position = b;
encoding = c;
callback = d;
}
}
const buf = dataToBuffer(a, encoding);
if (tipa !== 'string') {
if (typeof length === 'undefined')
length = buf.length;
}
else {
offset = 0;
length = buf.length;
}
const cb = validateCallback(callback);
return [fd, tipa === 'string', buf, offset, length, position, cb];
};
exports.getWriteArgs = getWriteArgs;
const getWriteSyncArgs = (fd, a, b, c, d) => {
validateFd(fd);
let encoding;
let offset;
let length;
let position;
const isBuffer = typeof a !== 'string';
if (isBuffer) {
offset = (b || 0) | 0;
length = c;
position = d;
}
else {
position = b;
encoding = c;
}
const buf = dataToBuffer(a, encoding);
if (isBuffer) {
if (typeof length === 'undefined') {
length = buf.length;
}
}
else {
offset = 0;
length = buf.length;
}
return [fd, buf, offset || 0, length, position];
};
exports.getWriteSyncArgs = getWriteSyncArgs;
function bufferToEncoding(buffer, encoding) {
if (!encoding || encoding === 'buffer')
return buffer;
else
return buffer.toString(encoding);
}
function isReadableStream(stream) {
return (stream !== null &&
typeof stream === 'object' &&
typeof stream.pipe === 'function' &&
typeof stream.on === 'function' &&
stream.readable === true);
}
const isSeparator = (str, i) => {
let char = str[i];
return i > 0 && (char === '/' || (exports.isWin && char === '\\'));
};
const removeTrailingSeparator = (str) => {
let i = str.length - 1;
if (i < 2)
return str;
while (isSeparator(str, i))
i--;
return str.substr(0, i + 1);
};
const normalizePath = (str, stripTrailing) => {
if (typeof str !== 'string')
throw new TypeError('expected a string');
str = str.replace(/[\\\/]+/g, '/');
if (stripTrailing !== false)
str = removeTrailingSeparator(str);
return str;
};
const unixify = (filepath, stripTrailing = true) => {
if (exports.isWin) {
filepath = normalizePath(filepath, stripTrailing);
return filepath.replace(/^([a-zA-Z]+:|\.\/)/, '');
}
return filepath;
};
exports.unixify = unixify;
//# sourceMappingURL=util.js.map
+1
View File
File diff suppressed because one or more lines are too long