ktfile 0.0.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/LICENSE +21 -0
- package/README.md +2 -0
- package/index.min.js +1 -0
- package/package.json +44 -0
- package/types/IFile.d.ts +91 -0
- package/types/Utils.d.ts +4 -0
- package/types/async/FileAsync.d.ts +675 -0
- package/types/async/IAsyncFS.d.ts +64 -0
- package/types/kfile.d.ts +7 -0
- package/types/sync/FileSync.d.ts +667 -0
- package/types/sync/ISyncFS.d.ts +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Oğuzhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/index.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let t=[];function s(s,e=t){s.startsWith("/")?(e=[],s=s.slice(1)):e=[...e];const i=s.split("/");for(const t of i)".."===t?e.pop():"."!==t&&""!==t&&e.push(t);return e}"undefined"!=typeof process&&"cwd"in process&&"function"==typeof process.cwd&&(t=s(process.cwd()));const e=new Map;function i(t,s,e){const i=t.listeners(s);t.removeAllListeners(s);for(const n of i)n!==e&&t.on(s,n);t.on(s,e)}function n(){for(const[t,s]of e.entries())new d(t).delete(s);e.clear(),"undefined"!=typeof process?(process.off("SIGINT",r),process.off("SIGTERM",l),process.off("exit",n)):"undefined"!=typeof window&&(window.removeEventListener("beforeunload",n),window.removeEventListener("pagehide",n))}function r(){n(),process.exit(130)}function l(){n(),process.exit(143)}function a(){"undefined"!=typeof process?(i(process,"exit",n),i(process,"SIGINT",r),i(process,"SIGTERM",l)):"undefined"!=typeof window&&(window.addEventListener("beforeunload",n),window.addEventListener("pagehide",n))}class h{split;constructor(t){this.split="string"==typeof t?s(t):[...t]}get fullPath(){return 0===this.split.length?this.separator:this.split.join(this.separator)}createWriteStream(t){if("object"==typeof this.fs&&"createWriteStream"in this.fs&&"function"==typeof this.fs.createWriteStream)return this.fs.createWriteStream(this.split.join("/"),t);throw new Error("File system does not support createWriteStream")}createReadStream(t){if("object"==typeof this.fs&&"createReadStream"in this.fs&&"function"==typeof this.fs.createReadStream)return this.fs.createReadStream(this.split.join("/"),t);throw new Error("File system does not support createReadStream")}createAppendStream(t){if("object"==typeof this.fs&&"createWriteStream"in this.fs&&"function"==typeof this.fs.createWriteStream)return this.fs.createWriteStream(this.split.join("/"),{flags:"a",encoding:t});throw new Error("File system does not support createAppendStream")}createInputStream(t){if("object"==typeof this.fs&&"createReadStream"in this.fs&&"function"==typeof this.fs.createReadStream)return this.fs.createReadStream(this.split.join("/"),{flags:"r",encoding:t});throw new Error("File system does not support createInputStream")}}async function u(t){try{return t().then(()=>!0).catch(()=>!1)}catch(t){return!1}}async function f(t){try{return t().then(t=>t).catch(()=>null)}catch(t){return null}}class c extends h{static fs;static createTempFile(t,s="kfile-temp",e=".tmp"){if(!("mkdTemp"in c.fs))throw new Error("mkdTemp is not available in the current FS.");const i=t?t.fullPath:".",n=this.fs.mkdtemp(`${i}/${s}-`);return new c(`${n}${e}`)}get fs(){return c.fs}canExecute(){return u(()=>this.fs.access(this.fullPath,this.fs?.constants?.X_OK??1))}async setExecutable(t=!0){return await u(()=>this.fs.chmod(this.fullPath,t?493:420))?this:null}canRead(){return u(()=>this.fs.access(this.fullPath,this.fs?.constants?.R_OK??4))}async setReadable(t=!0){return await u(()=>this.fs.chmod(this.fullPath,t?420:0))?this:null}canWrite(){return u(()=>this.fs.access(this.fullPath,this.fs?.constants?.W_OK??2))}async setWritable(t=!0){return await u(()=>this.fs.chmod(this.fullPath,t?420:292))?this:null}creationTime(){return f(()=>this.fs.stat(this.fullPath).then(t=>t.birthtime).catch(()=>null))}async setCreationTime(t){return await u(()=>this.fs.utimes(this.fullPath,t,t))?this:null}async lastModified(){return await f(()=>this.fs.stat(this.fullPath).then(t=>t.mtime).catch(()=>null))}async setLastModified(t){return await u(()=>this.fs.utimes(this.fullPath,t,t))?this:null}exists(){return f(()=>this.fs.exists(this.fullPath))}lastAccess(){return f(()=>this.fs.stat(this.fullPath).then(t=>t.atime).catch(()=>null))}get name(){return this.fullPath.split(this.separator).pop()||""}get nameWithoutExtension(){const t=this.name,s=t.lastIndexOf(".");return-1===s?t:t.substring(0,s)}get extension(){const t=this.name,s=t.lastIndexOf(".");return-1===s?"":t.substring(s+1)}get parent(){return 0===this.split.length?null:new c(this.split.slice(0,-1))}get uri(){return`file://${this.fullPath}`}get separator(){return"sep"in this.fs&&"string"==typeof this.fs.sep?this.fs.sep:"/"}isDirectory(){return f(()=>this.fs.stat(this.fullPath).then(t=>t.isDirectory()).catch(()=>null))}isFile(){return f(()=>this.fs.stat(this.fullPath).then(t=>t.isFile()).catch(()=>null))}get isHidden(){return this.name.startsWith(".")||this.fullPath.split(this.separator).some(t=>t.startsWith("."))}isSymbolicLink(){return f(()=>this.fs.lstat(this.fullPath).then(t=>t.isSymbolicLink()).catch(()=>null))}size(){return f(()=>this.fs.stat(this.fullPath).then(t=>t.size).catch(()=>null))}async sizeKB(){const t=await this.size();return null!==t?t/1024:null}async sizeMB(){const t=await this.size();return null!==t?t/1048576:null}async sizeGB(){const t=await this.size();return null!==t?t/1073741824:null}to(...t){return new c(this.fullPath+"/"+t.join("/"))}contains(t){if(t.split.length<=this.split.length)return!1;for(let s=0;s<this.split.length;s++)if(this.split[s]!==t.split[s])return!1;return!0}async createFile(){return await this.exists()?await this.isFile()?this:null:await this.write("")?this:null}async delete(t,s=t){if(t){if("rmSync"in this.fs)return await u(()=>this.fs.rm(this.fullPath,{recursive:!0,force:s}))?this:null;if("rmdirSync"in this.fs)return await u(()=>this.fs.rmdir(this.fullPath,{recursive:!0}))?this:null;let t=!1;for(const s of await this.listFiles()||[])await s.delete(!0)||(t=!0);if(t)return null}return await u(()=>this.fs.unlink(this.fullPath))?this:null}deleteOnExit(t){e.set(this.fullPath,t),a()}async clear(t){if(t){const t=await this.listFiles();if(null===t)return null;let s=!1;for(const e of t||[])await e.delete(!0)||(s=!0);return s?null:this}return await this.write(""),null}async listFiles(){if(!this.isDirectory)return null;const t=await f(()=>this.fs.readdir(this.fullPath));return t?t.map(t=>new c(`${this.fullPath}/${t}`)):null}listFilenames(){return f(()=>this.fs.readdir(this.fullPath))}async mkdir(t=!1){return await u(()=>this.fs.mkdir(this.fullPath,{recursive:t}))?this:null}async mkdirs(){return await this.mkdir(!0)?this:null}async renameTo(t,s,e){return this.fullPath===t.fullPath?this:!t.exists||s||await t.delete(e)?(e&&await(this.parent?.mkdirs()),await u(()=>this.fs.rename(this.fullPath,t.fullPath))?this:null):null}async copyTo(t,s,e){if(this.fullPath===t.fullPath)return this;if(!this.exists)return null;if(t.exists&&!s&&!await t.delete(e))return null;if(this.isFile){const s=await this.read();return null===s?null:await t.write(s)?this:null}if(!await t.mkdir(e))return null;const i=await this.listFiles();if(null===i)return null;let n=!1;for(const r of i){const i=t.to(r.name);await r.copyTo(i,s,e)||(n=!0)}return n?null:this}async*walk(){if(this.isDirectory){yield this;for(const t of await this.listFiles()||[])yield*t.walk()}else yield this}read(t){return f(()=>this.fs.readFile(this.fullPath,t))}async readLines(t="utf8"){const s=await this.read(t);return"string"==typeof s?s.split(/\r?\n/):null}async readJSON(){const t=await this.read("utf8");if("string"!=typeof t)return null;try{return JSON.parse(t)}catch(t){return null}}async readlink(){if(!this.isSymbolicLink)return null;const t=await f(()=>this.fs.readlink(this.fullPath));return t?new c(t):null}async write(t,s){return null!==s&&"object"==typeof s&&"write"in s&&"function"==typeof s.write&&(t=s.write()),await u(()=>this.fs.writeFile(this.fullPath,t,s))?this:null}async writeJSON(t){return await u(()=>this.write(JSON.stringify(t,null,2)))?this:null}async append(t,s){return await u(()=>this.fs.appendFile(this.fullPath,t,s))?this:null}get sync(){return new d(this.split)}}function o(t){try{return t(),!0}catch(t){return!1}}function p(t){try{return t()}catch(t){return null}}class d extends h{static fs;static createTempFile(t,s="kfile-temp",e=".tmp"){if(!("mkdTempSync"in d.fs))throw new Error("mkdTempSync is not available in the current FS.");const i=t?t.fullPath:".",n=this.fs.mkdtempSync(`${i}/${s}-`);return new d(`${n}${e}`)}get fs(){return d.fs}get canExecute(){return o(()=>this.fs.accessSync(this.fullPath,this.fs?.constants?.X_OK??1))}set canExecute(t){o(()=>this.fs.chmodSync(this.fullPath,t?493:420))}get canRead(){return o(()=>this.fs.accessSync(this.fullPath,this.fs?.constants?.R_OK??4))}set canRead(t){o(()=>this.fs.chmodSync(this.fullPath,t?420:0))}get canWrite(){return o(()=>this.fs.accessSync(this.fullPath,this.fs?.constants?.W_OK??2))}set canWrite(t){o(()=>this.fs.chmodSync(this.fullPath,t?420:292))}get creationTime(){return p(()=>this.fs.statSync(this.fullPath).birthtime)}set creationTime(t){o(()=>this.fs.utimesSync(this.fullPath,t,t))}get lastModified(){return p(()=>this.fs.statSync(this.fullPath).mtime)}set lastModified(t){o(()=>this.fs.utimesSync(this.fullPath,t,t))}get exists(){return p(()=>this.fs.existsSync(this.fullPath))}get lastAccess(){return p(()=>this.fs.statSync(this.fullPath).atime)}get name(){return this.fullPath.split(this.separator).pop()||""}get nameWithoutExtension(){const t=this.name,s=t.lastIndexOf(".");return-1===s?t:t.substring(0,s)}get extension(){const t=this.name,s=t.lastIndexOf(".");return-1===s?"":t.substring(s+1)}get parent(){return 0===this.split.length?null:new d(this.split.slice(0,-1))}get uri(){return`file://${this.fullPath}`}get separator(){return"sep"in this.fs&&"string"==typeof this.fs.sep?this.fs.sep:"/"}get isDirectory(){return p(()=>this.fs.statSync(this.fullPath).isDirectory())}get isFile(){return p(()=>this.fs.statSync(this.fullPath).isFile())}get isHidden(){return this.name.startsWith(".")||this.fullPath.split(this.separator).some(t=>t.startsWith("."))}get isSymbolicLink(){return p(()=>this.fs.lstatSync(this.fullPath).isSymbolicLink())}get size(){return p(()=>this.fs.statSync(this.fullPath).size)}get sizeKB(){const t=this.size;return null!==t?t/1024:null}get sizeMB(){const t=this.size;return null!==t?t/1048576:null}get sizeGB(){const t=this.size;return null!==t?t/1073741824:null}to(...t){return new d(this.fullPath+"/"+t.join("/"))}contains(t){if(t.split.length<=this.split.length)return!1;for(let s=0;s<this.split.length;s++)if(this.split[s]!==t.split[s])return!1;return!0}createFile(){return this.exists?this.isFile?this:null:this.write("")?this:null}delete(t,s=t){if(t){if("rmSync"in this.fs)return o(()=>this.fs.rmSync(this.fullPath,{recursive:!0,force:s}))?this:null;if("rmdirSync"in this.fs)return o(()=>this.fs.rmdirSync(this.fullPath,{recursive:!0}))?this:null;let t=!1;for(const s of this.listFiles()||[])s.delete(!0)||(t=!0);if(t)return null}return o(()=>this.fs.unlinkSync(this.fullPath))?this:null}deleteOnExit(t){e.set(this.fullPath,t),a()}clear(t){if(t){const t=this.listFiles();if(null===t)return null;let s=!1;for(const e of t||[])e.delete(!0)||(s=!0);return s?null:this}return this.write(""),null}listFiles(){if(!this.isDirectory)return null;const t=p(()=>this.fs.readdirSync(this.fullPath));return t?t.map(t=>new d(`${this.fullPath}/${t}`)):null}listFilenames(){return p(()=>this.fs.readdirSync(this.fullPath))}mkdir(t=!1){return o(()=>this.fs.mkdirSync(this.fullPath,{recursive:t}))?this:null}mkdirs(){return this.mkdir(!0)?this:null}renameTo(t,s,e){return this.fullPath===t.fullPath?this:!t.exists||s||t.delete(e)?(e&&this.parent?.mkdirs(),o(()=>this.fs.renameSync(this.fullPath,t.fullPath))?this:null):null}copyTo(t,s,e){if(this.fullPath===t.fullPath)return this;if(!this.exists)return null;if(t.exists&&!s&&!t.delete(e))return null;if(this.isFile){const s=this.read();return null===s?null:t.write(s)?this:null}if(!t.mkdir(e))return null;const i=this.listFiles();if(null===i)return null;let n=!1;for(const r of i){const i=t.to(r.name);r.copyTo(i,s,e)||(n=!0)}return n?null:this}*walk(){if(this.isDirectory){yield this;for(const t of this.listFiles()||[])yield*t.walk()}else yield this}read(t){return p(()=>this.fs.readFileSync(this.fullPath,t))}readLines(t="utf8"){const s=this.read(t);return"string"==typeof s?s.split(/\r?\n/):null}readJSON(){const t=this.read("utf8");if("string"!=typeof t)return null;try{return JSON.parse(t)}catch(t){return null}}readlink(){if(!this.isSymbolicLink)return null;const t=p(()=>this.fs.readlinkSync(this.fullPath));return t?new d(t):null}write(t,s){return null!==s&&"object"==typeof s&&"write"in s&&"function"==typeof s.write&&(t=s.write()),o(()=>this.fs.writeFileSync(this.fullPath,t,s))?this:null}writeJSON(t){return o(()=>this.write(JSON.stringify(t,null,2)))?this:null}append(t,s){return o(()=>this.fs.appendFileSync(this.fullPath,t,s))?this:null}get async(){return new c(this.split)}}function y(t){d.fs=t,c.fs=t.promises}function m(t){return new d(t)}function w(t){return new c(t)}if("undefined"!=typeof process)try{y(await import("fs"))}catch{}export{d as File,c as FileAsync,d as FileSync,w as fileAsync,m as fileSync,y as initFS};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ktfile",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Fluent, modern and chainable File API\n\n",
|
|
5
|
+
"main": "index.min.js",
|
|
6
|
+
"types": "types/kfile.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "tsx tests/test.ts",
|
|
10
|
+
"build": "tsc && rollup -c",
|
|
11
|
+
"clean": "node tests/clean.js",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"postpublish": "npm run clean"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
17
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
18
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
19
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
20
|
+
"@types/node": "^22.9.0",
|
|
21
|
+
"rollup": "^4.22.4"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"file",
|
|
25
|
+
"file api",
|
|
26
|
+
"file system",
|
|
27
|
+
"fs",
|
|
28
|
+
"nodejs",
|
|
29
|
+
"typescript",
|
|
30
|
+
"javascript",
|
|
31
|
+
"modern",
|
|
32
|
+
"fluent",
|
|
33
|
+
"chainable",
|
|
34
|
+
"async",
|
|
35
|
+
"await",
|
|
36
|
+
"promise"
|
|
37
|
+
],
|
|
38
|
+
"author": "OguzhanUmutlu",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/OguzhanUmutlu/kfile.git"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/types/IFile.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare abstract class IFile<FS extends object> {
|
|
2
|
+
protected readonly split: string[];
|
|
3
|
+
constructor(pt: string | string[]);
|
|
4
|
+
abstract get fs(): FS;
|
|
5
|
+
abstract get separator(): string;
|
|
6
|
+
get fullPath(): string;
|
|
7
|
+
/**
|
|
8
|
+
* @description Creates a writable stream for the file.
|
|
9
|
+
* This method is used to write data to the file. If the file does not exist,
|
|
10
|
+
* it will be created. If the file already exists, it will be overwritten.
|
|
11
|
+
* @example
|
|
12
|
+
* const file = new FileSync("path/to/file.txt");
|
|
13
|
+
* const stream = file.createWriteStream("utf8");
|
|
14
|
+
* stream.write("Hello, World!");
|
|
15
|
+
* stream.end();
|
|
16
|
+
* @param {BufferEncoding} [encoding] - The encoding to use for the stream.
|
|
17
|
+
* If not specified, the stream will return raw Buffer objects.
|
|
18
|
+
* @returns {WritableStream} A writable stream that can be used to write data to the file.
|
|
19
|
+
* The stream accepts data in chunks and writes it to the file.
|
|
20
|
+
* It also emits 'finish' when all data has been written.
|
|
21
|
+
* @throws {Error} If the file system does not support creating a writable stream.
|
|
22
|
+
* This can happen if the underlying file system does not implement the `createWriteStream`
|
|
23
|
+
* method or if the file system is not compatible with this operation.
|
|
24
|
+
*/
|
|
25
|
+
createWriteStream(encoding?: BufferEncoding): WritableStream;
|
|
26
|
+
/**
|
|
27
|
+
* @description Creates a readable stream for the file.
|
|
28
|
+
* This method is used to read the contents of the file as a stream.
|
|
29
|
+
* It is useful for reading large files or when you want to process the file data in chunks.
|
|
30
|
+
* @example
|
|
31
|
+
* const file = new FileSync("path/to/file.txt");
|
|
32
|
+
* const stream = file.createReadStream("utf8");
|
|
33
|
+
* stream.on("data", (chunk) => {
|
|
34
|
+
* console.log("Chunk:", chunk);
|
|
35
|
+
* });
|
|
36
|
+
* stream.on("end", () => {
|
|
37
|
+
* console.log("Finished reading the file.");
|
|
38
|
+
* });
|
|
39
|
+
* @param {BufferEncoding} [encoding] - The encoding to use for the stream.
|
|
40
|
+
* If not specified, the stream will return raw Buffer objects.
|
|
41
|
+
* @returns {ReadableStream} A readable stream that can be used to read the file.
|
|
42
|
+
* The stream emits 'data' events for each chunk of data read from the file.
|
|
43
|
+
* It also emits 'end' when the end of the file is reached.
|
|
44
|
+
* @throws {Error} If the file system does not support creating a readable stream.
|
|
45
|
+
* This can happen if the underlying file system does not implement the `createReadStream`
|
|
46
|
+
* method or if the file system is not compatible with this operation.
|
|
47
|
+
*/
|
|
48
|
+
createReadStream(encoding?: BufferEncoding): ReadableStream;
|
|
49
|
+
/**
|
|
50
|
+
* @description Creates a writable stream for appending data to the file.
|
|
51
|
+
* This method is used to write data to the end of the file without overwriting existing
|
|
52
|
+
* content. It is useful for logging or adding new data to a file.
|
|
53
|
+
* @example
|
|
54
|
+
* const file = new FileSync("path/to/file.txt");
|
|
55
|
+
* const stream = file.createAppendStream("utf8");
|
|
56
|
+
* stream.write("New data to append");
|
|
57
|
+
* stream.end();
|
|
58
|
+
* @param {BufferEncoding} [encoding] - The encoding to use for the stream.
|
|
59
|
+
* If not specified, the stream will return raw Buffer objects.
|
|
60
|
+
* @returns {WritableStream} A writable stream that can be used to append data to the file.
|
|
61
|
+
* The stream accepts data in chunks and writes it to the end of the file.
|
|
62
|
+
* It also emits 'finish' when all data has been written.
|
|
63
|
+
* @throws {Error} If the file system does not support creating a writable stream for appending data.
|
|
64
|
+
* This can happen if the underlying file system does not implement the `createWriteStream`
|
|
65
|
+
* method or if the file system is not compatible with this operation.
|
|
66
|
+
*/
|
|
67
|
+
createAppendStream(encoding?: BufferEncoding): WritableStream;
|
|
68
|
+
/**
|
|
69
|
+
* @description Creates a readable stream for the file.
|
|
70
|
+
* This method is used to read the contents of the file as a stream.
|
|
71
|
+
* It is useful for reading large files or when you want to process the file data in chunks.
|
|
72
|
+
* @example
|
|
73
|
+
* const file = new FileSync("path/to/file.txt");
|
|
74
|
+
* const stream = file.createInputStream("utf8");
|
|
75
|
+
* stream.on("data", (chunk) => {
|
|
76
|
+
* console.log("Chunk:", chunk);
|
|
77
|
+
* });
|
|
78
|
+
* stream.on("end", () => {
|
|
79
|
+
* console.log("Finished reading the file.");
|
|
80
|
+
* });
|
|
81
|
+
* @param {BufferEncoding} [encoding] - The encoding to use for the stream.
|
|
82
|
+
* If not specified, the stream will return raw Buffer objects.
|
|
83
|
+
* @returns {ReadableStream} A readable stream that can be used to read the file.
|
|
84
|
+
* The stream emits 'data' events for each chunk of data read from the file.
|
|
85
|
+
* It also emits 'end' when the end of the file is reached.
|
|
86
|
+
* @throws {Error} If the file system does not support creating a readable stream.
|
|
87
|
+
* This can happen if the underlying file system does not implement the `createReadStream`
|
|
88
|
+
* method or if the file system is not compatible with this operation.
|
|
89
|
+
*/
|
|
90
|
+
createInputStream(encoding?: BufferEncoding): ReadableStream;
|
|
91
|
+
}
|
package/types/Utils.d.ts
ADDED