@bemoje/fs 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/deleteOlderThan.cjs +30 -0
- package/lib/deleteOlderThan.d.cts +8 -0
- package/lib/deleteOlderThan.d.ts +8 -0
- package/lib/deleteOlderThan.js +24 -0
- package/lib/getFileAge.cjs +18 -0
- package/lib/getFileAge.d.cts +7 -0
- package/lib/getFileAge.d.ts +7 -0
- package/lib/getFileAge.js +12 -0
- package/lib/getFirstFileInDir.cjs +26 -0
- package/lib/getFirstFileInDir.d.cts +6 -0
- package/lib/getFirstFileInDir.d.ts +6 -0
- package/lib/getFirstFileInDir.js +20 -0
- package/lib/index.cjs +188 -0
- package/lib/index.d.cts +13 -0
- package/lib/index.d.ts +13 -0
- package/lib/readFileFirstLine.cjs +26 -0
- package/lib/readFileFirstLine.d.cts +6 -0
- package/lib/readFileFirstLine.d.ts +6 -0
- package/lib/readFileFirstLine.js +19 -0
- package/lib/removeDataUrlSchemePrefix.cjs +12 -0
- package/lib/removeDataUrlSchemePrefix.d.cts +8 -0
- package/lib/removeDataUrlSchemePrefix.d.ts +8 -0
- package/lib/removeDataUrlSchemePrefix.js +10 -0
- package/lib/updateFile.cjs +19 -0
- package/lib/updateFile.d.cts +7 -0
- package/lib/updateFile.d.ts +7 -0
- package/lib/updateFile.js +13 -0
- package/lib/updateFileLines.cjs +21 -0
- package/lib/updateFileLines.d.cts +8 -0
- package/lib/updateFileLines.d.ts +8 -0
- package/lib/updateFileLines.js +15 -0
- package/lib/updateFileLinesSync.cjs +21 -0
- package/lib/updateFileLinesSync.d.cts +6 -0
- package/lib/updateFileLinesSync.d.ts +6 -0
- package/lib/updateFileLinesSync.js +15 -0
- package/lib/updateFileSync.cjs +19 -0
- package/lib/updateFileSync.d.cts +6 -0
- package/lib/updateFileSync.d.ts +6 -0
- package/lib/updateFileSync.js +13 -0
- package/lib/updateJsonFile.cjs +23 -0
- package/lib/updateJsonFile.d.cts +8 -0
- package/lib/updateJsonFile.d.ts +8 -0
- package/lib/updateJsonFile.js +17 -0
- package/lib/updateJsonFileSync.cjs +23 -0
- package/lib/updateJsonFileSync.d.cts +6 -0
- package/lib/updateJsonFileSync.d.ts +6 -0
- package/lib/updateJsonFileSync.js +17 -0
- package/lib/walkDirectory.cjs +71 -0
- package/lib/walkDirectory.d.cts +48 -0
- package/lib/walkDirectory.d.ts +48 -0
- package/lib/walkDirectory.js +63 -0
- package/package.json +209 -19
- package/index.d.ts +0 -113
- /package/{index.mjs → lib/index.js} +0 -0
package/index.d.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Stats } from 'fs-extra';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Delete files older than a given timestamp
|
|
5
|
-
* @param dp The dirpath to a folder in which to delete files from
|
|
6
|
-
* @param ageThreshold The age in milliseconds to compare against
|
|
7
|
-
*/
|
|
8
|
-
declare function deleteOlderThan(dp: string, ageThreshold: number): Promise<void>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves the age of a file in milliseconds.
|
|
12
|
-
* @param filepath - The path to the file.
|
|
13
|
-
*/
|
|
14
|
-
declare function getFileAge(filepath: string): Promise<number>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get the name of the first file (not directory) found in a directory.
|
|
18
|
-
*/
|
|
19
|
-
declare function getFirstFileInDir(dirpath: string): Promise<string>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Reads the first line of a file asynchronously.
|
|
23
|
-
*/
|
|
24
|
-
declare function readFileFirstLine(filepath: string): Promise<string>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Removes the data URL scheme prefix from a given string.
|
|
28
|
-
* @param dataUrl - The string to remove the prefix from.
|
|
29
|
-
* @returns The string with the prefix removed.
|
|
30
|
-
*/
|
|
31
|
-
declare function removeDataUrlSchemePrefix(dataUrl: string): string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Updates a file by reading its content, applying a transformation function, and writing back the result.
|
|
35
|
-
* Creates the file and directories if they don't exist.
|
|
36
|
-
*/
|
|
37
|
-
declare function updateFile(filepath: string, update: (fileContent: string) => string | Promise<string>): Promise<void>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Updates a file by applying a transformation function to an array of lines.
|
|
41
|
-
* The transformation can return either a string (the entire new content) or an array of lines.
|
|
42
|
-
* Creates the file and directories if they don't exist.
|
|
43
|
-
*/
|
|
44
|
-
declare function updateFileLines(filepath: string, update: (fileContentLines: string[]) => string | string[] | Promise<string | string[]>): Promise<void>;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Synchronous version of `updateFileLines`.
|
|
48
|
-
*/
|
|
49
|
-
declare function updateFileLinesSync(filepath: string, update: (fileContentLines: string[]) => string | string[]): void;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Synchronous version of `updateFile`.
|
|
53
|
-
*/
|
|
54
|
-
declare function updateFileSync(filepath: string, update: (fileContent: string) => string): void;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Updates a JSON file by applying a transformation function to the parsed content.
|
|
58
|
-
* If the file doesn't exist or can't be parsed, uses the default value.
|
|
59
|
-
* Creates the file and directories if they don't exist.
|
|
60
|
-
*/
|
|
61
|
-
declare function updateJsonFile<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R | Promise<R>, defaultValue?: T): Promise<R>;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Synchronous version of `updateJsonFile`.
|
|
65
|
-
*/
|
|
66
|
-
declare function updateJsonFileSync<T extends object, R extends object>(filepath: string, update: (parsedFileContent: T) => R, defaultValue?: T): R;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Walk a directory recursively and return an array of paths.
|
|
70
|
-
*/
|
|
71
|
-
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithoutStats): string[];
|
|
72
|
-
/**
|
|
73
|
-
* Walk a directory recursively and return an array of [path: string, stats: Stats] tuples.
|
|
74
|
-
*/
|
|
75
|
-
declare function walkDirectory(dirpath: string, options: WalkDirectoryOptionsWithStats): [path: string, stats: Stats][];
|
|
76
|
-
/**
|
|
77
|
-
* Options for @see walkDirectory
|
|
78
|
-
*/
|
|
79
|
-
interface WalkDirectoryOptions {
|
|
80
|
-
/**
|
|
81
|
-
* Return stats for each path.
|
|
82
|
-
*/
|
|
83
|
-
stats?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Only return either files or directories.
|
|
86
|
-
*/
|
|
87
|
-
only?: 'files' | 'directories';
|
|
88
|
-
/**
|
|
89
|
-
* Recursion depth limit.
|
|
90
|
-
*/
|
|
91
|
-
maxDepth?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Determine whether to walk a given directory.
|
|
94
|
-
*/
|
|
95
|
-
filter?: (dirpath: string, basename: string) => boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Follow symbolic links.
|
|
98
|
-
*/
|
|
99
|
-
followSymlinks?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* On filesystems where inodes are not unique (eg. windows), some files may not be walked due to inode collision.
|
|
102
|
-
* Turning off this behavior may be required but at the same time may lead to hitting max_depth via link loop.
|
|
103
|
-
*/
|
|
104
|
-
ignoreInodes?: boolean;
|
|
105
|
-
}
|
|
106
|
-
interface WalkDirectoryOptionsWithoutStats extends WalkDirectoryOptions {
|
|
107
|
-
stats?: false;
|
|
108
|
-
}
|
|
109
|
-
interface WalkDirectoryOptionsWithStats extends WalkDirectoryOptions {
|
|
110
|
-
stats: true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { type WalkDirectoryOptions, type WalkDirectoryOptionsWithStats, type WalkDirectoryOptionsWithoutStats, deleteOlderThan, getFileAge, getFirstFileInDir, readFileFirstLine, removeDataUrlSchemePrefix, updateFile, updateFileLines, updateFileLinesSync, updateFileSync, updateJsonFile, updateJsonFileSync, walkDirectory };
|
|
File without changes
|