Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@file-services/types

Package Overview
Dependencies
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/types - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

6

cjs/base-api-async.d.ts

@@ -1,4 +0,4 @@

import { IFileSystemStats, BufferEncoding, CallbackFnVoid, CallbackFn, WriteFileOptions, ReadFileOptions, IDirectoryEntry } from './common-fs-types';
import { IFileSystemPath } from './path';
import { IWatchService } from './watch-api';
import type { IFileSystemStats, BufferEncoding, CallbackFnVoid, CallbackFn, WriteFileOptions, ReadFileOptions, IDirectoryEntry } from './common-fs-types';
import type { IFileSystemPath } from './path';
import type { IWatchService } from './watch-api';
/**

@@ -5,0 +5,0 @@ * ASYNC-only base file system.

@@ -1,4 +0,4 @@

import { IFileSystemStats, BufferEncoding, WriteFileOptions, ReadFileOptions, IDirectoryEntry } from './common-fs-types';
import { IFileSystemPath } from './path';
import { IWatchService } from './watch-api';
import type { IFileSystemStats, BufferEncoding, WriteFileOptions, ReadFileOptions, IDirectoryEntry } from './common-fs-types';
import type { IFileSystemPath } from './path';
import type { IWatchService } from './watch-api';
/**

@@ -5,0 +5,0 @@ * SYNC-only base file system.

@@ -1,3 +0,3 @@

import { IBaseFileSystemSync } from './base-api-sync';
import { IBaseFileSystemAsync } from './base-api-async';
import type { IBaseFileSystemSync } from './base-api-sync';
import type { IBaseFileSystemAsync } from './base-api-async';
export * from './base-api-sync';

@@ -4,0 +4,0 @@ export * from './base-api-async';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./base-api-sync"), exports);
__exportStar(require("./base-api-async"), exports);
//# sourceMappingURL=base-api.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSystemConstants = void 0;
var FileSystemConstants;

@@ -4,0 +5,0 @@ (function (FileSystemConstants) {

@@ -1,3 +0,3 @@

import { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types';
import { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async';
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types';
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async';
/**

@@ -4,0 +4,0 @@ * ASYNC-only file system.

@@ -1,3 +0,3 @@

import { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types';
import { IBaseFileSystemSync } from './base-api-sync';
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types';
import type { IBaseFileSystemSync } from './base-api-sync';
/**

@@ -4,0 +4,0 @@ * SYNC-only file system.

@@ -1,3 +0,3 @@

import { IFileSystemSync } from './extended-api-sync';
import { IFileSystemAsync } from './extended-api-async';
import type { IFileSystemSync } from './extended-api-sync';
import type { IFileSystemAsync } from './extended-api-async';
export * from './extended-api-sync';

@@ -4,0 +4,0 @@ export * from './extended-api-async';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./extended-api-sync"), exports);
__exportStar(require("./extended-api-async"), exports);
//# sourceMappingURL=extended-api.js.map
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./common-fs-types"));
__exportStar(require("./base-api"), exports);
__exportStar(require("./common-fs-types"), exports);
__exportStar(require("./extended-api"), exports);
__exportStar(require("./path"), exports);
__exportStar(require("./watch-api"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { IFileSystemStats } from './common-fs-types';
import type { IFileSystemStats } from './common-fs-types';
/**

@@ -3,0 +3,0 @@ * File watching service.

{
"name": "@file-services/types",
"description": "Common file system interfaces",
"version": "2.2.0",
"version": "3.0.0",
"main": "cjs/index.js",

@@ -6,0 +6,0 @@ "types": "cjs/index.d.ts",

# @file-services/types
[![npm version](https://img.shields.io/npm/v/@file-services/types.svg)](https://www.npmjs.com/package/@file-services/types)

@@ -3,0 +4,0 @@

@@ -1,12 +0,12 @@

import {
IFileSystemStats,
BufferEncoding,
CallbackFnVoid,
CallbackFn,
WriteFileOptions,
ReadFileOptions,
IDirectoryEntry
import type {
IFileSystemStats,
BufferEncoding,
CallbackFnVoid,
CallbackFn,
WriteFileOptions,
ReadFileOptions,
IDirectoryEntry,
} from './common-fs-types';
import { IFileSystemPath } from './path';
import { IWatchService } from './watch-api';
import type { IFileSystemPath } from './path';
import type { IWatchService } from './watch-api';

@@ -18,181 +18,181 @@ /**

export interface IBaseFileSystemAsync extends IBaseFileSystemCallbackActions, IFileSystemPath {
watchService: IWatchService;
caseSensitive: boolean;
watchService: IWatchService;
caseSensitive: boolean;
promises: IBaseFileSystemPromiseActions;
promises: IBaseFileSystemPromiseActions;
}
export interface IBaseFileSystemCallbackActions {
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFile(sourcePath: string, destinationPath: string, callback: CallbackFnVoid): void;
copyFile(sourcePath: string, destinationPath: string, flags: number, callback: CallbackFnVoid): void;
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFile(sourcePath: string, destinationPath: string, callback: CallbackFnVoid): void;
copyFile(sourcePath: string, destinationPath: string, flags: number, callback: CallbackFnVoid): void;
/**
* Read the entire contents of a file.
*/
readFile(
path: string,
options: { encoding?: null; flag?: string } | undefined | null,
callback: CallbackFn<Buffer>
): void;
readFile(
path: string,
options: { encoding: BufferEncoding; flag?: string } | BufferEncoding,
callback: CallbackFn<string>
): void;
readFile(path: string, options: ReadFileOptions, callback: CallbackFn<string | Buffer>): void;
readFile(path: string, callback: CallbackFn<Buffer>): void;
/**
* Read the entire contents of a file.
*/
readFile(
path: string,
options: { encoding?: null; flag?: string } | undefined | null,
callback: CallbackFn<Buffer>
): void;
readFile(
path: string,
options: { encoding: BufferEncoding; flag?: string } | BufferEncoding,
callback: CallbackFn<string>
): void;
readFile(path: string, options: ReadFileOptions, callback: CallbackFn<string | Buffer>): void;
readFile(path: string, callback: CallbackFn<Buffer>): void;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFile(path: string, data: string | Buffer, options: WriteFileOptions, callback: CallbackFnVoid): void;
writeFile(path: string, data: string | Buffer, callback: CallbackFnVoid): void;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFile(path: string, data: string | Buffer, options: WriteFileOptions, callback: CallbackFnVoid): void;
writeFile(path: string, data: string | Buffer, callback: CallbackFnVoid): void;
/**
* Delete a name and possibly the file it refers to.
*/
unlink(filePath: string, callback: CallbackFnVoid): void;
/**
* Delete a name and possibly the file it refers to.
*/
unlink(filePath: string, callback: CallbackFnVoid): void;
/**
* Read the names of items in a directory.
*/
readdir(directoryPath: string, callback: CallbackFn<string[]>): void;
readdir(
directoryPath: string,
options: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null | undefined,
callback: CallbackFn<string[]>
): void;
readdir(directoryPath: string, options: { withFileTypes: true }, callback: CallbackFn<IDirectoryEntry[]>): void;
/**
* Read the names of items in a directory.
*/
readdir(directoryPath: string, callback: CallbackFn<string[]>): void;
readdir(
directoryPath: string,
options: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null | undefined,
callback: CallbackFn<string[]>
): void;
readdir(directoryPath: string, options: { withFileTypes: true }, callback: CallbackFn<IDirectoryEntry[]>): void;
/**
* Create a directory.
*/
mkdir(filePath: string, callback: CallbackFnVoid): void;
/**
* Create a directory.
*/
mkdir(filePath: string, callback: CallbackFnVoid): void;
/**
* Delete a directory.
*/
rmdir(filePath: string, callback: CallbackFnVoid): void;
/**
* Delete a directory.
*/
rmdir(filePath: string, callback: CallbackFnVoid): void;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
exists(path: string, callback: (exists: boolean) => void): void;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
exists(path: string, callback: (exists: boolean) => void): void;
/**
* Get path's `IFileSystemStats`.
*/
stat(path: string, callback: CallbackFn<IFileSystemStats>): void;
/**
* Get path's `IFileSystemStats`.
*/
stat(path: string, callback: CallbackFn<IFileSystemStats>): void;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstat(path: string, callback: CallbackFn<IFileSystemStats>): void;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstat(path: string, callback: CallbackFn<IFileSystemStats>): void;
/**
* Gets the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpath(path: string, callback: CallbackFn<string>): void;
/**
* Gets the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpath(path: string, callback: CallbackFn<string>): void;
/**
* Rename (move) a file or a directory
*/
rename(sourcePath: string, destinationPath: string, callback: CallbackFnVoid): void;
/**
* Rename (move) a file or a directory
*/
rename(sourcePath: string, destinationPath: string, callback: CallbackFnVoid): void;
/**
* Read value of a symbolic link.
*/
readlink(path: string, callback: CallbackFn<string>): void;
/**
* Read value of a symbolic link.
*/
readlink(path: string, callback: CallbackFn<string>): void;
}
export interface IBaseFileSystemPromiseActions {
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFile(sourcePath: string, destinationPath: string, flags?: number): Promise<void>;
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFile(sourcePath: string, destinationPath: string, flags?: number): Promise<void>;
/**
* Read the entire contents of a file.
*/
readFile(path: string, options?: { encoding?: null; flag?: string } | null): Promise<Buffer>;
readFile(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): Promise<string>;
readFile(path: string, options: ReadFileOptions): Promise<string | Buffer>;
/**
* Read the entire contents of a file.
*/
readFile(path: string, options?: { encoding?: null; flag?: string } | null): Promise<Buffer>;
readFile(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): Promise<string>;
readFile(path: string, options: ReadFileOptions): Promise<string | Buffer>;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFile(path: string, data: string | Buffer, options?: WriteFileOptions): Promise<void>;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFile(path: string, data: string | Buffer, options?: WriteFileOptions): Promise<void>;
/**
* Delete a name and possibly the file it refers to.
*/
unlink(filePath: string): Promise<void>;
/**
* Delete a name and possibly the file it refers to.
*/
unlink(filePath: string): Promise<void>;
/**
* Read the names of items in a directory.
*/
readdir(
directoryPath: string,
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null
): Promise<string[]>;
readdir(directoryPath: string, options: { withFileTypes: true }): Promise<IDirectoryEntry[]>;
/**
* Read the names of items in a directory.
*/
readdir(
directoryPath: string,
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null
): Promise<string[]>;
readdir(directoryPath: string, options: { withFileTypes: true }): Promise<IDirectoryEntry[]>;
/**
* Create a directory.
*/
mkdir(directoryPath: string): Promise<void>;
/**
* Create a directory.
*/
mkdir(directoryPath: string): Promise<void>;
/**
* Delete a directory.
*/
rmdir(directoryPath: string): Promise<void>;
/**
* Delete a directory.
*/
rmdir(directoryPath: string): Promise<void>;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
exists(path: string): Promise<boolean>;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
exists(path: string): Promise<boolean>;
/**
* Get path's `IFileSystemStats`.
*/
stat(path: string): Promise<IFileSystemStats>;
/**
* Get path's `IFileSystemStats`.
*/
stat(path: string): Promise<IFileSystemStats>;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstat(path: string): Promise<IFileSystemStats>;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstat(path: string): Promise<IFileSystemStats>;
/**
* Gets the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpath(path: string): Promise<string>;
/**
* Gets the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpath(path: string): Promise<string>;
/**
* Rename (move) a file or a directory
*/
rename(sourcePath: string, destinationPath: string): Promise<void>;
/**
* Rename (move) a file or a directory
*/
rename(sourcePath: string, destinationPath: string): Promise<void>;
/**
* Read value of a symbolic link.
*/
readlink(path: string): Promise<string>;
/**
* Read value of a symbolic link.
*/
readlink(path: string): Promise<string>;
}

@@ -1,10 +0,10 @@

import {
IFileSystemStats,
BufferEncoding,
WriteFileOptions,
ReadFileOptions,
IDirectoryEntry
import type {
IFileSystemStats,
BufferEncoding,
WriteFileOptions,
ReadFileOptions,
IDirectoryEntry,
} from './common-fs-types';
import { IFileSystemPath } from './path';
import { IWatchService } from './watch-api';
import type { IFileSystemPath } from './path';
import type { IWatchService } from './watch-api';

@@ -16,100 +16,100 @@ /**

export interface IBaseFileSystemSync extends IBaseFileSystemSyncActions, IFileSystemPath {
watchService: IWatchService;
caseSensitive: boolean;
watchService: IWatchService;
caseSensitive: boolean;
}
export interface IBaseFileSystemSyncActions {
/**
* Get the current working directory.
* Non-absolute calls to any file system method are resolved using this path.
*
* @returns absolute path to the current working directory.
*/
cwd(): string;
/**
* Get the current working directory.
* Non-absolute calls to any file system method are resolved using this path.
*
* @returns absolute path to the current working directory.
*/
cwd(): string;
/**
* Change the working directory.
*
* @directoryPath path to the new working directory.
*/
chdir(directoryPath: string): void;
/**
* Change the working directory.
*
* @directoryPath path to the new working directory.
*/
chdir(directoryPath: string): void;
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFileSync(sourcePath: string, destinationPath: string, flags?: number): void;
/**
* Copy `sourcePath` to `destinationPath`.
* By default, if destination already exists, it will be overwritten.
*
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists.
*/
copyFileSync(sourcePath: string, destinationPath: string, flags?: number): void;
/**
* Read the entire contents of a file.
*/
readFileSync(path: string, options?: { encoding?: null; flag?: string } | null): Buffer;
readFileSync(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): string;
readFileSync(path: string, options: ReadFileOptions): string | Buffer;
/**
* Read the entire contents of a file.
*/
readFileSync(path: string, options?: { encoding?: null; flag?: string } | null): Buffer;
readFileSync(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): string;
readFileSync(path: string, options: ReadFileOptions): string | Buffer;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFileSync(path: string, data: string | Buffer, options?: WriteFileOptions): void;
/**
* Write data to a file, replacing the file if already exists.
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8').
*/
writeFileSync(path: string, data: string | Buffer, options?: WriteFileOptions): void;
/**
* Delete a name and possibly the file it refers to.
*/
unlinkSync(filePath: string): void;
/**
* Delete a name and possibly the file it refers to.
*/
unlinkSync(filePath: string): void;
/**
* Read the names of items in a directory.
*/
readdirSync(
directoryPath: string,
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null
): string[];
readdirSync(directoryPath: string, options: { withFileTypes: true }): IDirectoryEntry[];
/**
* Read the names of items in a directory.
*/
readdirSync(
directoryPath: string,
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null
): string[];
readdirSync(directoryPath: string, options: { withFileTypes: true }): IDirectoryEntry[];
/**
* Create a new directory.
*/
mkdirSync(directoryPath: string): void;
/**
* Create a new directory.
*/
mkdirSync(directoryPath: string): void;
/**
* Delete an existing directory.
*/
rmdirSync(directoryPath: string): void;
/**
* Delete an existing directory.
*/
rmdirSync(directoryPath: string): void;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
existsSync(path: string): boolean;
/**
* Check if a path points to an existing file/directory/link.
*
* @param path possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
existsSync(path: string): boolean;
/**
* Get path's `IFileSystemStats`.
*/
statSync(path: string): IFileSystemStats;
/**
* Get path's `IFileSystemStats`.
*/
statSync(path: string): IFileSystemStats;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstatSync(path: string): IFileSystemStats;
/**
* Get path's `IFileSystemStats`. Does not dereference symbolic links.
*/
lstatSync(path: string): IFileSystemStats;
/**
* Get the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpathSync(path: string): string;
/**
* Get the canonicalized absolute pathname.
* If path is linked, returns the actual target path.
*/
realpathSync(path: string): string;
/**
* Rename (move) a file or a directory
*/
renameSync(sourcePath: string, destinationPath: string): void;
/**
* Rename (move) a file or a directory
*/
renameSync(sourcePath: string, destinationPath: string): void;
/**
* Read value of a symbolic link.
*/
readlinkSync(path: string): string;
/**
* Read value of a symbolic link.
*/
readlinkSync(path: string): string;
}

@@ -1,3 +0,3 @@

import { IBaseFileSystemSync } from './base-api-sync';
import { IBaseFileSystemAsync } from './base-api-async';
import type { IBaseFileSystemSync } from './base-api-sync';
import type { IBaseFileSystemAsync } from './base-api-async';

@@ -4,0 +4,0 @@ export * from './base-api-sync';

@@ -5,5 +5,5 @@ export type BufferEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex';

declare global {
interface Buffer {
toString(ecoding?: BufferEncoding): string;
}
interface Buffer {
toString(ecoding?: BufferEncoding): string;
}
}

@@ -16,6 +16,6 @@

export type WriteFileOptions =
| { encoding?: string | null; mode?: number | string; flag?: string }
| string
| null
| undefined;
| { encoding?: string | null; mode?: number | string; flag?: string }
| string
| null
| undefined;

@@ -25,11 +25,11 @@ export type ReadFileOptions = { encoding?: string | null; flag?: string } | string | null | undefined;

export enum FileSystemConstants {
/**
* When passed as a flag to `copyFile` or `copyFileSync`,
* causes operation to fail if destination already exists.
*/
COPYFILE_EXCL = 1
/**
* When passed as a flag to `copyFile` or `copyFileSync`,
* causes operation to fail if destination already exists.
*/
COPYFILE_EXCL = 1,
}
export interface IDirectoryContents {
[nodeName: string]: string | IDirectoryContents;
[nodeName: string]: string | IDirectoryContents;
}

@@ -41,23 +41,23 @@

export interface IDirectoryEntry {
/**
* Base name of the entry.
*
* @example `package.json`
*/
name: string;
/**
* Base name of the entry.
*
* @example `package.json`
*/
name: string;
/**
* Whether the entry points to a file.
*/
isFile(): boolean;
/**
* Whether the entry points to a file.
*/
isFile(): boolean;
/**
* Whether the entry points to a directory.
*/
isDirectory(): boolean;
/**
* Whether the entry points to a directory.
*/
isDirectory(): boolean;
/**
* Whether the entry is a symbolic link.
*/
isSymbolicLink(): boolean;
/**
* Whether the entry is a symbolic link.
*/
isSymbolicLink(): boolean;
}

@@ -69,26 +69,26 @@

export interface IFileSystemStats {
/**
* Creation time
*/
birthtime: Date;
/**
* Creation time
*/
birthtime: Date;
/**
* Modification time
*/
mtime: Date;
/**
* Modification time
*/
mtime: Date;
/**
* is the path pointing to a file
*/
isFile(): boolean;
/**
* is the path pointing to a file
*/
isFile(): boolean;
/**
* is the path pointing to a directory
*/
isDirectory(): boolean;
/**
* is the path pointing to a directory
*/
isDirectory(): boolean;
/**
* is the path pointing to a symbolic link
*/
isSymbolicLink(): boolean;
/**
* is the path pointing to a symbolic link
*/
isSymbolicLink(): boolean;
}

@@ -100,46 +100,46 @@

export interface IFileSystemDescriptor {
/**
* Base name of the file system node.
*
* @example 'package.json'
*/
name: string;
/**
* Base name of the file system node.
*
* @example 'package.json'
*/
name: string;
/**
* Absolute path to the file system node.
*
* @example '/path/to/package.json'
*/
path: string;
/**
* Absolute path to the file system node.
*
* @example '/path/to/package.json'
*/
path: string;
/**
* Stats for the path
*/
stats: IFileSystemStats;
/**
* Stats for the path
*/
stats: IFileSystemStats;
}
export interface IWalkOptions {
/**
* Print errors using `console.error` when the walking operation
* encounters such.
*
* @default false
*/
printErrors?: boolean;
/**
* Print errors using `console.error` when the walking operation
* encounters such.
*
* @default false
*/
printErrors?: boolean;
/**
* Optional file filtering function that receives a file descriptor and returns
* whether it should be included in the result.
*
* @default true returned for all files.
*/
filterFile?(pathDesc: IFileSystemDescriptor): boolean;
/**
* Optional file filtering function that receives a file descriptor and returns
* whether it should be included in the result.
*
* @default true returned for all files.
*/
filterFile?(pathDesc: IFileSystemDescriptor): boolean;
/**
* Optional directory filtering function that receives a directory descriptor and returns
* whether it should be walked into.
*
* @default true returned for all directories.
*/
filterDirectory?(pathDesc: IFileSystemDescriptor): boolean;
/**
* Optional directory filtering function that receives a directory descriptor and returns
* whether it should be walked into.
*
* @default true returned for all directories.
*/
filterDirectory?(pathDesc: IFileSystemDescriptor): boolean;
}

@@ -1,3 +0,3 @@

import { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types';
import { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async';
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types';
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async';

@@ -9,3 +9,3 @@ /**

export interface IFileSystemAsync extends IBaseFileSystemAsync {
promises: IFileSystemPromiseActions;
promises: IFileSystemPromiseActions;
}

@@ -16,76 +16,76 @@

export interface IFileSystemExtendedPromiseActions {
/**
* Check if a path points to an existing file.
*
* @param filePath possible file path
* @param statFn optional custom stat function (e.g. lstat to detect links)
*/
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>;
/**
* Check if a path points to an existing file.
*
* @param filePath possible file path
* @param statFn optional custom stat function (e.g. lstat to detect links)
*/
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>;
/**
* Check if a path points to an existing directory.
*
* @param directoryPath possible directory path
* @param statFn optional custom stat function (e.g. lstatSync to detect links)
*/
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>;
/**
* Check if a path points to an existing directory.
*
* @param directoryPath possible directory path
* @param statFn optional custom stat function (e.g. lstatSync to detect links)
*/
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>;
/**
* Ensure that a directory and all its parent directories exist
*/
ensureDirectory(directoryPath: string): Promise<void>;
/**
* Ensure that a directory and all its parent directories exist
*/
ensureDirectory(directoryPath: string): Promise<void>;
/**
* Search for files inside `rootDirectory`.
*
* @returns absolute paths of all found files.
*/
findFiles(rootDirectory: string, options?: IWalkOptions): Promise<string[]>;
/**
* Search for files inside `rootDirectory`.
*
* @returns absolute paths of all found files.
*/
findFiles(rootDirectory: string, options?: IWalkOptions): Promise<string[]>;
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute path of first found file, or `undefined` if none found.
*/
findClosestFile(initialDirectoryPath: string, fileName: string): Promise<string | undefined>;
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute path of first found file, or `undefined` if none found.
*/
findClosestFile(initialDirectoryPath: string, fileName: string): Promise<string | undefined>;
/**
* Search for a specific file name in parent chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute paths of all found files (ordered from inner most directory and up).
*/
findFilesInAncestors(initialDirectory: string, fileName: string): Promise<string[]>;
/**
* Search for a specific file name in parent chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute paths of all found files (ordered from inner most directory and up).
*/
findFilesInAncestors(initialDirectory: string, fileName: string): Promise<string[]>;
/**
* Populates the provided directory with given contents.
*
* @returns absolute paths of written files.
*/
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]>;
/**
* Populates the provided directory with given contents.
*
* @returns absolute paths of written files.
*/
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]>;
/**
* Recursively remove a path.
*/
remove(path: string): Promise<void>;
/**
* Recursively remove a path.
*/
remove(path: string): Promise<void>;
/**
* Read a file and parse it using `JSON.parse`.
*
* @param filePath path pointing to a `json` file.
* @param options text encoding to decode file with (defaults to `utf8`).
* @rejects if there is a reading or parsing error.
*/
readJsonFile(filePath: string, options?: BufferEncoding | { encoding: BufferEncoding } | null): Promise<unknown>;
/**
* Read a file and parse it using `JSON.parse`.
*
* @param filePath path pointing to a `json` file.
* @param options text encoding to decode file with (defaults to `utf8`).
* @rejects if there is a reading or parsing error.
*/
readJsonFile(filePath: string, options?: BufferEncoding | { encoding: BufferEncoding } | null): Promise<unknown>;
/**
* Recursively copy a directory and its contents.
*/
copyDirectory(sourcePath: string, destinationPath: string): Promise<void>;
/**
* Recursively copy a directory and its contents.
*/
copyDirectory(sourcePath: string, destinationPath: string): Promise<void>;
/**
* Recursively walk over a directory and its contents.
*/
// walk(rootDirectory: string, options?: IWalkOptions): Promise<IFileSystemDescriptor[]>
/**
* Recursively walk over a directory and its contents.
*/
// walk(rootDirectory: string, options?: IWalkOptions): Promise<IFileSystemDescriptor[]>
}

@@ -1,3 +0,3 @@

import { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types';
import { IBaseFileSystemSync } from './base-api-sync';
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types';
import type { IBaseFileSystemSync } from './base-api-sync';

@@ -11,76 +11,76 @@ /**

export interface IFileSystemExtendedSyncActions {
/**
* Check if a path points to an existing file.
*
* @param filePath possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean;
/**
* Check if a path points to an existing file.
*
* @param filePath possible file path.
* @param statFn optional custom stat function (e.g. lstat to detect links).
*/
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean;
/**
* Check if a path points to an existing directory.
*
* @param directoryPath possible directory path.
* @param statFn optional custom stat function (e.g. lstatSync to detect links).
*/
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean;
/**
* Check if a path points to an existing directory.
*
* @param directoryPath possible directory path.
* @param statFn optional custom stat function (e.g. lstatSync to detect links).
*/
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean;
/**
* Ensure that a directory and all its parent directories exist
*/
ensureDirectorySync(directoryPath: string): void;
/**
* Ensure that a directory and all its parent directories exist
*/
ensureDirectorySync(directoryPath: string): void;
/**
* Search for files inside `rootDirectory`.
*
* @returns absolute paths of all found files.
*/
findFilesSync(rootDirectory: string, options?: IWalkOptions): string[];
/**
* Search for files inside `rootDirectory`.
*
* @returns absolute paths of all found files.
*/
findFilesSync(rootDirectory: string, options?: IWalkOptions): string[];
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute path of first found file, or `undefined` if none found.
*/
findClosestFileSync(initialDirectoryPath: string, fileName: string): string | undefined;
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute path of first found file, or `undefined` if none found.
*/
findClosestFileSync(initialDirectoryPath: string, fileName: string): string | undefined;
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute paths of all found files (ordered from inner most directory and up).
*/
findFilesInAncestorsSync(initialDirectory: string, fileName: string): string[];
/**
* Search for a specific file name in parent directory chain.
* Useful for finding configuration or manifest files.
*
* @returns absolute paths of all found files (ordered from inner most directory and up).
*/
findFilesInAncestorsSync(initialDirectory: string, fileName: string): string[];
/**
* Populates the provided directory with given contents.
*
* @returns absolute paths of written files.
*/
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[];
/**
* Populates the provided directory with given contents.
*
* @returns absolute paths of written files.
*/
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[];
/**
* Recursively remove a path.
*/
removeSync(path: string): void;
/**
* Recursively remove a path.
*/
removeSync(path: string): void;
/**
* Read a file and parse it using `JSON.parse`.
*
* @param filePath path pointing to a `json` file.
* @param options text encoding to decode file with (defaults to `utf8`).
* @throws if there is a reading or parsing error.
*/
readJsonFileSync(filePath: string, options?: BufferEncoding | { encoding: BufferEncoding } | null): unknown;
/**
* Read a file and parse it using `JSON.parse`.
*
* @param filePath path pointing to a `json` file.
* @param options text encoding to decode file with (defaults to `utf8`).
* @throws if there is a reading or parsing error.
*/
readJsonFileSync(filePath: string, options?: BufferEncoding | { encoding: BufferEncoding } | null): unknown;
/**
* Recursively copy a directory and its contents.
*/
copyDirectorySync(sourcePath: string, destinationPath: string): void;
/**
* Recursively copy a directory and its contents.
*/
copyDirectorySync(sourcePath: string, destinationPath: string): void;
/**
* Recursively walk over a directory and its contents.
*/
// walkSync(rootDirectory: string, options?: IWalkOptions): IFileSystemDescriptor[]
/**
* Recursively walk over a directory and its contents.
*/
// walkSync(rootDirectory: string, options?: IWalkOptions): IFileSystemDescriptor[]
}

@@ -1,3 +0,3 @@

import { IFileSystemSync } from './extended-api-sync';
import { IFileSystemAsync } from './extended-api-async';
import type { IFileSystemSync } from './extended-api-sync';
import type { IFileSystemAsync } from './extended-api-async';

@@ -4,0 +4,0 @@ export * from './extended-api-sync';

@@ -6,102 +6,102 @@ /**

export interface IFileSystemPath {
/**
* The platform-specific file separator. '\\' or '/'.
*/
readonly sep: string;
/**
* The platform-specific file separator. '\\' or '/'.
*/
readonly sep: string;
/**
* The platform-specific file delimiter. ';' or ':'.
*/
readonly delimiter: string;
/**
* The platform-specific file delimiter. ';' or ':'.
*/
readonly delimiter: string;
/**
* Normalize a string path, reducing '..' and '.' parts.
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
*
* @param p string path to normalize.
*/
normalize(p: string): string;
/**
* Normalize a string path, reducing '..' and '.' parts.
* When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
*
* @param p string path to normalize.
*/
normalize(p: string): string;
/**
* Join all arguments together and normalize the resulting path.
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
*
* @param paths paths to join.
*/
join(...paths: string[]): string;
/**
* Join all arguments together and normalize the resulting path.
* Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
*
* @param paths paths to join.
*/
join(...paths: string[]): string;
/**
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
*
* Starting from leftmost {from} parameter, resolves {to} to an absolute path.
*
* If {to} isn't already absolute, {from} arguments are prepended in right to left order,
* until an absolute path is found. If after using all {from} paths still no absolute path is found,
* the current working directory is used as well. The resulting path is normalized,
* and trailing slashes are removed unless the path gets resolved to the root directory.
*
* @param pathSegments string paths to join. Non-string arguments are ignored.
*/
resolve(...pathSegments: string[]): string;
/**
* The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
*
* Starting from leftmost {from} parameter, resolves {to} to an absolute path.
*
* If {to} isn't already absolute, {from} arguments are prepended in right to left order,
* until an absolute path is found. If after using all {from} paths still no absolute path is found,
* the current working directory is used as well. The resulting path is normalized,
* and trailing slashes are removed unless the path gets resolved to the root directory.
*
* @param pathSegments string paths to join. Non-string arguments are ignored.
*/
resolve(...pathSegments: string[]): string;
/**
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
*
* @param path path to test.
*/
isAbsolute(p: string): boolean;
/**
* Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
*
* @param path path to test.
*/
isAbsolute(p: string): boolean;
/**
* Solve the relative path from {from} to {to}.
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
*/
relative(from: string, to: string): string;
/**
* Solve the relative path from {from} to {to}.
* At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
*/
relative(from: string, to: string): string;
/**
* Return the directory name of a path. Similar to the Unix dirname command.
*
* @param p the path to evaluate.
*/
dirname(p: string): string;
/**
* Return the directory name of a path. Similar to the Unix dirname command.
*
* @param p the path to evaluate.
*/
dirname(p: string): string;
/**
* Return the last portion of a path. Similar to the Unix basename command.
* Often used to extract the file name from a fully qualified path.
*
* @param p the path to evaluate.
* @param ext optionally, an extension to remove from the result.
*/
basename(p: string, ext?: string): string;
/**
* Return the last portion of a path. Similar to the Unix basename command.
* Often used to extract the file name from a fully qualified path.
*
* @param p the path to evaluate.
* @param ext optionally, an extension to remove from the result.
*/
basename(p: string, ext?: string): string;
/**
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
*
* @param p the path to evaluate.
*/
extname(p: string): string;
/**
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
* If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
*
* @param p the path to evaluate.
*/
extname(p: string): string;
/**
* Returns an object from a path string - the opposite of format().
*
* @param pathString path to evaluate.
*/
parse(p: string): IParsedPath;
/**
* Returns an object from a path string - the opposite of format().
*
* @param pathString path to evaluate.
*/
parse(p: string): IParsedPath;
/**
* Returns a path string from an object - the opposite of parse().
*/
format(pP: IFormatInputPathObject): string;
/**
* Returns a path string from an object - the opposite of parse().
*/
format(pP: IFormatInputPathObject): string;
/**
* Posix specific pathing.
* Same as parent object on posix.
*/
readonly posix: IFileSystemPath;
/**
* Posix specific pathing.
* Same as parent object on posix.
*/
readonly posix: IFileSystemPath;
/**
* Windows specific pathing.
* Same as parent object on windows
*/
readonly win32: IFileSystemPath;
/**
* Windows specific pathing.
* Same as parent object on windows
*/
readonly win32: IFileSystemPath;
}

@@ -113,53 +113,53 @@

export interface IParsedPath {
/**
* The root of the path such as '/' or 'c:\'
*/
root: string;
/**
* The root of the path such as '/' or 'c:\'
*/
root: string;
/**
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
*/
dir: string;
/**
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
*/
dir: string;
/**
* The file name including extension (if any) such as 'index.html'
*/
base: string;
/**
* The file name including extension (if any) such as 'index.html'
*/
base: string;
/**
* The file extension (if any) such as '.html'
*/
ext: string;
/**
* The file extension (if any) such as '.html'
*/
ext: string;
/**
* The file name without extension (if any) such as 'index'
*/
name: string;
/**
* The file name without extension (if any) such as 'index'
*/
name: string;
}
export interface IFormatInputPathObject {
/**
* The root of the path such as '/' or 'c:\'
*/
root?: string;
/**
* The root of the path such as '/' or 'c:\'
*/
root?: string;
/**
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
*/
dir?: string;
/**
* The full directory path such as '/home/user/dir' or 'c:\path\dir'
*/
dir?: string;
/**
* The file name including extension (if any) such as 'index.html'
*/
base?: string;
/**
* The file name including extension (if any) such as 'index.html'
*/
base?: string;
/**
* The file extension (if any) such as '.html'
*/
ext?: string;
/**
* The file extension (if any) such as '.html'
*/
ext?: string;
/**
* The file name without extension (if any) such as 'index'
*/
name?: string;
/**
* The file name without extension (if any) such as 'index'
*/
name?: string;
}

@@ -1,2 +0,2 @@

import { IFileSystemStats } from './common-fs-types';
import type { IFileSystemStats } from './common-fs-types';

@@ -8,36 +8,36 @@ /**

export interface IWatchService {
/**
* Start watching `path` (file or directory).
* if `listener` is provided, it will receive watch events for `path`.
* Any global listeners will also receive events for path.
*/
watchPath(path: string, listener?: WatchEventListener): Promise<void>;
/**
* Start watching `path` (file or directory).
* if `listener` is provided, it will receive watch events for `path`.
* Any global listeners will also receive events for path.
*/
watchPath(path: string, listener?: WatchEventListener): Promise<void>;
/**
* Stop watching `path` (file or directory).
* if `listener` is provided, it will stop receiving watch events for `path`.
* if `listener is not provided, path will be unwatched with its listeners cleared.
*/
unwatchPath(path: string, listener?: WatchEventListener): Promise<void>;
/**
* Stop watching `path` (file or directory).
* if `listener` is provided, it will stop receiving watch events for `path`.
* if `listener is not provided, path will be unwatched with its listeners cleared.
*/
unwatchPath(path: string, listener?: WatchEventListener): Promise<void>;
/**
* Unwatch all watched paths.
*/
unwatchAllPaths(): Promise<void>;
/**
* Unwatch all watched paths.
*/
unwatchAllPaths(): Promise<void>;
/**
* Add a global watch event listener.
* It will receive watch events for all watched paths.
*/
addGlobalListener(listener: WatchEventListener): void;
/**
* Add a global watch event listener.
* It will receive watch events for all watched paths.
*/
addGlobalListener(listener: WatchEventListener): void;
/**
* Remove a global watch event listener.
*/
removeGlobalListener(listener: WatchEventListener): void;
/**
* Remove a global watch event listener.
*/
removeGlobalListener(listener: WatchEventListener): void;
/**
* Clears all registered global watch event listeners.
*/
clearGlobalListeners(): void;
/**
* Clears all registered global watch event listeners.
*/
clearGlobalListeners(): void;
}

@@ -50,4 +50,4 @@

export interface IWatchEvent {
path: string;
stats: IFileSystemStats | null;
path: string;
stats: IFileSystemStats | null;
}

@@ -54,0 +54,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc