@file-services/types
Advanced tools
Comparing version 8.3.3 to 9.0.0
@@ -1,4 +0,4 @@ | ||
import type { IFileSystemStats, BufferEncoding, CallbackFnVoid, CallbackFn, WriteFileOptions, ReadFileOptions, IDirectoryEntry, RmOptions } from './common-fs-types'; | ||
import type { IFileSystemPath } from './path'; | ||
import type { IWatchService } from './watch-api'; | ||
import type { IFileSystemStats, BufferEncoding, CallbackFnVoid, CallbackFn, WriteFileOptions, ReadFileOptions, IDirectoryEntry, RmOptions } from "./common-fs-types"; | ||
import type { IFileSystemPath } from "./path"; | ||
import type { IWatchService } from "./watch-api"; | ||
/** | ||
@@ -28,3 +28,3 @@ * ASYNC-only base file system. | ||
flag?: string; | ||
} | undefined | null, callback: CallbackFn<Buffer>): void; | ||
} | undefined | null, callback: CallbackFn<Uint8Array>): void; | ||
readFile(path: string, options: { | ||
@@ -34,7 +34,7 @@ encoding: BufferEncoding; | ||
} | BufferEncoding, callback: CallbackFn<string>): void; | ||
readFile(path: string, options: ReadFileOptions | undefined, callback: CallbackFn<string | Buffer>): void; | ||
readFile(path: string, callback: CallbackFn<Buffer>): void; | ||
readFile(path: string, options: ReadFileOptions | undefined, callback: CallbackFn<string | Uint8Array>): void; | ||
readFile(path: string, callback: CallbackFn<Uint8Array>): 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -112,3 +112,3 @@ writeFile(path: string, data: string | Uint8Array, options: WriteFileOptions, callback: CallbackFnVoid): void; | ||
flag?: string; | ||
} | null): Promise<Buffer>; | ||
} | null): Promise<Uint8Array>; | ||
readFile(path: string, options: { | ||
@@ -118,6 +118,6 @@ encoding: BufferEncoding; | ||
} | BufferEncoding): Promise<string>; | ||
readFile(path: string, options?: ReadFileOptions): Promise<string | Buffer>; | ||
readFile(path: string, options?: ReadFileOptions): Promise<string | Uint8Array>; | ||
/** | ||
* 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -180,3 +180,3 @@ writeFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>; | ||
*/ | ||
symlink(target: string, path: string, type?: 'dir' | 'file' | 'junction'): Promise<void>; | ||
symlink(target: string, path: string, type?: "dir" | "file" | "junction"): Promise<void>; | ||
/** | ||
@@ -183,0 +183,0 @@ * Removes files and directories. |
@@ -1,4 +0,4 @@ | ||
import type { IFileSystemStats, BufferEncoding, WriteFileOptions, ReadFileOptions, IDirectoryEntry, StatSyncOptions, RmOptions } from './common-fs-types'; | ||
import type { IFileSystemPath } from './path'; | ||
import type { IWatchService } from './watch-api'; | ||
import type { IFileSystemStats, BufferEncoding, WriteFileOptions, ReadFileOptions, IDirectoryEntry, StatSyncOptions, RmOptions } from "./common-fs-types"; | ||
import type { IFileSystemPath } from "./path"; | ||
import type { IWatchService } from "./watch-api"; | ||
/** | ||
@@ -39,3 +39,3 @@ * SYNC-only base file system. | ||
flag?: string; | ||
} | null): Buffer; | ||
} | null): Uint8Array; | ||
readFileSync(path: string, options: { | ||
@@ -45,6 +45,6 @@ encoding: BufferEncoding; | ||
} | BufferEncoding): string; | ||
readFileSync(path: string, options?: ReadFileOptions): string | Buffer; | ||
readFileSync(path: string, options?: ReadFileOptions): string | Uint8Array; | ||
/** | ||
* 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -122,3 +122,3 @@ writeFileSync(path: string, data: string | Uint8Array, options?: WriteFileOptions): void; | ||
*/ | ||
symlinkSync(target: string, path: string, type?: 'dir' | 'file' | 'junction'): void; | ||
symlinkSync(target: string, path: string, type?: "dir" | "file" | "junction"): void; | ||
/** | ||
@@ -125,0 +125,0 @@ * Removes files and directories. |
@@ -1,5 +0,5 @@ | ||
import type { IBaseFileSystemSync } from './base-api-sync'; | ||
import type { IBaseFileSystemAsync } from './base-api-async'; | ||
export * from './base-api-sync'; | ||
export * from './base-api-async'; | ||
import type { IBaseFileSystemSync } from "./base-api-sync"; | ||
import type { IBaseFileSystemAsync } from "./base-api-async"; | ||
export * from "./base-api-sync"; | ||
export * from "./base-api-async"; | ||
/** | ||
@@ -6,0 +6,0 @@ * SYNC and ASYNC base file system. |
@@ -1,7 +0,2 @@ | ||
export type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex'; | ||
declare global { | ||
interface Buffer { | ||
toString(ecoding?: BufferEncoding): string; | ||
} | ||
} | ||
export type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"; | ||
export type CallbackFn<T> = (error: Error | null, value: T) => void; | ||
@@ -32,4 +27,4 @@ export type CallbackFnVoid = (error?: Error | null) => void; | ||
} | ||
export interface IDirectoryContents { | ||
[nodeName: string]: string | IDirectoryContents; | ||
export interface IDirectoryContents<T extends Uint8Array | string = string> { | ||
[nodeName: string]: T | IDirectoryContents<T>; | ||
} | ||
@@ -36,0 +31,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types'; | ||
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async'; | ||
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from "./common-fs-types"; | ||
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from "./base-api-async"; | ||
/** | ||
@@ -19,3 +19,3 @@ * ASYNC-only file system. | ||
*/ | ||
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>; | ||
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions["stat"]): Promise<boolean>; | ||
/** | ||
@@ -27,3 +27,3 @@ * Check if a path points to an existing directory. | ||
*/ | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>; | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions["stat"]): Promise<boolean>; | ||
/** | ||
@@ -58,3 +58,3 @@ * Ensure that a directory and all its parent directories exist | ||
*/ | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]>; | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents<string | Uint8Array>): Promise<string[]>; | ||
/** | ||
@@ -61,0 +61,0 @@ * Read a file and parse it using `JSON.parse`. |
@@ -1,3 +0,3 @@ | ||
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types'; | ||
import type { IBaseFileSystemSync } from './base-api-sync'; | ||
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from "./common-fs-types"; | ||
import type { IBaseFileSystemSync } from "./base-api-sync"; | ||
/** | ||
@@ -16,3 +16,3 @@ * SYNC-only file system. | ||
*/ | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync["statSync"]): boolean; | ||
/** | ||
@@ -24,3 +24,3 @@ * Check if a path points to an existing directory. | ||
*/ | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync["statSync"]): boolean; | ||
/** | ||
@@ -55,3 +55,3 @@ * Ensure that a directory and all its parent directories exist | ||
*/ | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[]; | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents<string | Uint8Array>): string[]; | ||
/** | ||
@@ -58,0 +58,0 @@ * Read a file and parse it using `JSON.parse`. |
@@ -1,5 +0,5 @@ | ||
import type { IFileSystemSync } from './extended-api-sync'; | ||
import type { IFileSystemAsync } from './extended-api-async'; | ||
export * from './extended-api-sync'; | ||
export * from './extended-api-async'; | ||
import type { IFileSystemSync } from "./extended-api-sync"; | ||
import type { IFileSystemAsync } from "./extended-api-async"; | ||
export * from "./extended-api-sync"; | ||
export * from "./extended-api-async"; | ||
/** | ||
@@ -6,0 +6,0 @@ * SYNC and ASYNC file system. |
@@ -1,6 +0,6 @@ | ||
export * from './base-api'; | ||
export * from './common-fs-types'; | ||
export * from './extended-api'; | ||
export * from './path'; | ||
export * from './watch-api'; | ||
export * from "./base-api"; | ||
export * from "./common-fs-types"; | ||
export * from "./extended-api"; | ||
export * from "./path"; | ||
export * from "./watch-api"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { 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": "8.3.3", | ||
"version": "9.0.0", | ||
"main": "./dist/fs-types.cjs", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
@@ -10,5 +10,5 @@ import type { | ||
RmOptions, | ||
} from './common-fs-types'; | ||
import type { IFileSystemPath } from './path'; | ||
import type { IWatchService } from './watch-api'; | ||
} from "./common-fs-types"; | ||
import type { IFileSystemPath } from "./path"; | ||
import type { IWatchService } from "./watch-api"; | ||
@@ -42,3 +42,3 @@ /** | ||
options: { encoding?: null; flag?: string } | undefined | null, | ||
callback: CallbackFn<Buffer> | ||
callback: CallbackFn<Uint8Array>, | ||
): void; | ||
@@ -48,10 +48,10 @@ readFile( | ||
options: { encoding: BufferEncoding; flag?: string } | BufferEncoding, | ||
callback: CallbackFn<string> | ||
callback: CallbackFn<string>, | ||
): void; | ||
readFile(path: string, options: ReadFileOptions | undefined, callback: CallbackFn<string | Buffer>): void; | ||
readFile(path: string, callback: CallbackFn<Buffer>): void; | ||
readFile(path: string, options: ReadFileOptions | undefined, callback: CallbackFn<string | Uint8Array>): void; | ||
readFile(path: string, callback: CallbackFn<Uint8Array>): 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -73,3 +73,3 @@ writeFile(path: string, data: string | Uint8Array, options: WriteFileOptions, callback: CallbackFnVoid): void; | ||
options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null | undefined, | ||
callback: CallbackFn<string[]> | ||
callback: CallbackFn<string[]>, | ||
): void; | ||
@@ -136,9 +136,9 @@ readdir(directoryPath: string, options: { withFileTypes: true }, callback: CallbackFn<IDirectoryEntry[]>): void; | ||
*/ | ||
readFile(path: string, options?: { encoding?: null; flag?: string } | null): Promise<Buffer>; | ||
readFile(path: string, options?: { encoding?: null; flag?: string } | null): Promise<Uint8Array>; | ||
readFile(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): Promise<string>; | ||
readFile(path: string, options?: ReadFileOptions): Promise<string | Buffer>; | ||
readFile(path: string, options?: ReadFileOptions): Promise<string | Uint8Array>; | ||
/** | ||
* 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -157,3 +157,3 @@ writeFile(path: string, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>; | ||
directoryPath: string, | ||
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null | ||
options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null, | ||
): Promise<string[]>; | ||
@@ -209,3 +209,3 @@ readdir(directoryPath: string, options: { withFileTypes: true }): Promise<IDirectoryEntry[]>; | ||
*/ | ||
symlink(target: string, path: string, type?: 'dir' | 'file' | 'junction'): Promise<void>; | ||
symlink(target: string, path: string, type?: "dir" | "file" | "junction"): Promise<void>; | ||
@@ -212,0 +212,0 @@ /** |
@@ -9,5 +9,5 @@ import type { | ||
RmOptions, | ||
} from './common-fs-types'; | ||
import type { IFileSystemPath } from './path'; | ||
import type { IWatchService } from './watch-api'; | ||
} from "./common-fs-types"; | ||
import type { IFileSystemPath } from "./path"; | ||
import type { IWatchService } from "./watch-api"; | ||
@@ -50,9 +50,9 @@ /** | ||
*/ | ||
readFileSync(path: string, options?: { encoding?: null; flag?: string } | null): Buffer; | ||
readFileSync(path: string, options?: { encoding?: null; flag?: string } | null): Uint8Array; | ||
readFileSync(path: string, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): string; | ||
readFileSync(path: string, options?: ReadFileOptions): string | Buffer; | ||
readFileSync(path: string, options?: ReadFileOptions): string | Uint8Array; | ||
/** | ||
* 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'). | ||
* `encoding` is used when a string `content` (not `Uint8Array`) was provided (with default 'utf8'). | ||
*/ | ||
@@ -71,3 +71,3 @@ writeFileSync(path: string, data: string | Uint8Array, options?: WriteFileOptions): void; | ||
directoryPath: string, | ||
options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null | ||
options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null, | ||
): string[]; | ||
@@ -130,3 +130,3 @@ readdirSync(directoryPath: string, options: { withFileTypes: true }): IDirectoryEntry[]; | ||
*/ | ||
symlinkSync(target: string, path: string, type?: 'dir' | 'file' | 'junction'): void; | ||
symlinkSync(target: string, path: string, type?: "dir" | "file" | "junction"): void; | ||
@@ -133,0 +133,0 @@ /** |
@@ -1,6 +0,6 @@ | ||
import type { IBaseFileSystemSync } from './base-api-sync'; | ||
import type { IBaseFileSystemAsync } from './base-api-async'; | ||
import type { IBaseFileSystemSync } from "./base-api-sync"; | ||
import type { IBaseFileSystemAsync } from "./base-api-async"; | ||
export * from './base-api-sync'; | ||
export * from './base-api-async'; | ||
export * from "./base-api-sync"; | ||
export * from "./base-api-async"; | ||
@@ -7,0 +7,0 @@ /** |
export type BufferEncoding = | ||
| 'ascii' | ||
| 'utf8' | ||
| 'utf-8' | ||
| 'utf16le' | ||
| 'ucs2' | ||
| 'ucs-2' | ||
| 'base64' | ||
| 'latin1' | ||
| 'binary' | ||
| 'hex'; | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "latin1" | ||
| "binary" | ||
| "hex"; | ||
// use global augmentation so that users without @types/node will have a partial Buffer interface | ||
declare global { | ||
interface Buffer { | ||
toString(ecoding?: BufferEncoding): string; | ||
} | ||
} | ||
export type CallbackFn<T> = (error: Error | null, value: T) => void; | ||
@@ -56,4 +49,4 @@ export type CallbackFnVoid = (error?: Error | null) => void; | ||
export interface IDirectoryContents { | ||
[nodeName: string]: string | IDirectoryContents; | ||
export interface IDirectoryContents<T extends Uint8Array | string = string> { | ||
[nodeName: string]: T | IDirectoryContents<T>; | ||
} | ||
@@ -60,0 +53,0 @@ |
@@ -1,3 +0,3 @@ | ||
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from './common-fs-types'; | ||
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from './base-api-async'; | ||
import type { IDirectoryContents, IWalkOptions, BufferEncoding } from "./common-fs-types"; | ||
import type { IBaseFileSystemAsync, IBaseFileSystemPromiseActions } from "./base-api-async"; | ||
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>; | ||
fileExists(filePath: string, statFn?: IBaseFileSystemPromiseActions["stat"]): Promise<boolean>; | ||
@@ -30,3 +30,3 @@ /** | ||
*/ | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions['stat']): Promise<boolean>; | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemPromiseActions["stat"]): Promise<boolean>; | ||
@@ -66,3 +66,3 @@ /** | ||
*/ | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]>; | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents<string | Uint8Array>): Promise<string[]>; | ||
@@ -69,0 +69,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from './common-fs-types'; | ||
import type { IBaseFileSystemSync } from './base-api-sync'; | ||
import type { IWalkOptions, IDirectoryContents, BufferEncoding } from "./common-fs-types"; | ||
import type { IBaseFileSystemSync } from "./base-api-sync"; | ||
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync["statSync"]): boolean; | ||
@@ -26,3 +26,3 @@ /** | ||
*/ | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync["statSync"]): boolean; | ||
@@ -62,3 +62,3 @@ /** | ||
*/ | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[]; | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents<string | Uint8Array>): string[]; | ||
@@ -65,0 +65,0 @@ /** |
@@ -1,6 +0,6 @@ | ||
import type { IFileSystemSync } from './extended-api-sync'; | ||
import type { IFileSystemAsync } from './extended-api-async'; | ||
import type { IFileSystemSync } from "./extended-api-sync"; | ||
import type { IFileSystemAsync } from "./extended-api-async"; | ||
export * from './extended-api-sync'; | ||
export * from './extended-api-async'; | ||
export * from "./extended-api-sync"; | ||
export * from "./extended-api-async"; | ||
@@ -7,0 +7,0 @@ /** |
@@ -1,5 +0,5 @@ | ||
export * from './base-api'; | ||
export * from './common-fs-types'; | ||
export * from './extended-api'; | ||
export * from './path'; | ||
export * from './watch-api'; | ||
export * from "./base-api"; | ||
export * from "./common-fs-types"; | ||
export * from "./extended-api"; | ||
export * from "./path"; | ||
export * from "./watch-api"; |
@@ -1,2 +0,2 @@ | ||
import type { IFileSystemStats } from './common-fs-types'; | ||
import type { IFileSystemStats } from "./common-fs-types"; | ||
@@ -3,0 +3,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9
81392
1619