-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ View Source + + fs-file.write.class.ts, line 66 + +
+ +diff --git a/docs/FSAsyncIterable.html b/docs/FSAsyncIterable.html index 392fafc..877f3ee 100644 --- a/docs/FSAsyncIterable.html +++ b/docs/FSAsyncIterable.html @@ -66,7 +66,7 @@ @@ -236,7 +236,7 @@
parallel
View Source - fs-async-iterable.class.ts, line 30 + fs-async-iterable.class.ts, line 57
@@ -521,7 +553,7 @@View Source - fs-async-iterable.class.ts, line 62 + fs-async-iterable.class.ts, line 116
@@ -558,7 +590,7 @@parallel
View Source - fs-async-iterable.class.ts, line 17 + fs-async-iterable.class.ts, line 18
@@ -831,7 +895,7 @@View Source - fs-async-iterable.class.ts, line 50 + fs-async-iterable.class.ts, line 104
@@ -932,7 +996,7 @@View Source - fs-async-iterable.class.ts, line 82 + fs-async-iterable.class.ts, line 136
diff --git a/docs/FSDir.html b/docs/FSDir.html index 0560306..d79c37c 100644 --- a/docs/FSDir.html +++ b/docs/FSDir.html @@ -66,7 +66,7 @@ diff --git a/docs/FSDirent.html b/docs/FSDirent.html index a813d20..bdc8ec2 100644 --- a/docs/FSDirent.html +++ b/docs/FSDirent.html @@ -66,7 +66,7 @@ diff --git a/docs/FSFile.html b/docs/FSFile.html index 3efbe95..a6cfa9f 100644 --- a/docs/FSFile.html +++ b/docs/FSFile.html @@ -66,7 +66,7 @@ diff --git a/docs/FSFileHash.html b/docs/FSFileHash.html index e47bbc6..766c20f 100644 --- a/docs/FSFileHash.html +++ b/docs/FSFileHash.html @@ -66,7 +66,7 @@ diff --git a/docs/FSFileRead.html b/docs/FSFileRead.html index 8cf808b..6b87ea9 100644 --- a/docs/FSFileRead.html +++ b/docs/FSFileRead.html @@ -66,7 +66,7 @@ diff --git a/docs/FSIterable.html b/docs/FSIterable.html index a8d487c..a417b0d 100644 --- a/docs/FSIterable.html +++ b/docs/FSIterable.html @@ -66,7 +66,7 @@ diff --git a/docs/PromiseLikeWriteStream.html b/docs/PromiseLikeWriteStream.html new file mode 100644 index 0000000..c282e72 --- /dev/null +++ b/docs/PromiseLikeWriteStream.html @@ -0,0 +1,196 @@ + + + + + + + +Interface
++ View Source + + fs-file.write.class.ts, line 66 + +
+ +import { writeFile, createWriteStream, appendFile, WriteFileOptions } from 'fs';
+ import { writeFile, createWriteStream, appendFile, WriteFileOptions, WriteStream } from 'fs';
/**
* Contains methods that write to file
*/
+export interface PromiseLikeWriteStream extends WriteStream, PromiseLike<void> {}
+
export class FSFileWrite {
constructor(public readonly path: string) {}
@@ -114,11 +116,20 @@ fs-file.write.class.ts
}
/**
- * Creates standart node fs WriteStream for this path.
+ * Creates fs WriteStream for this path.
* @param options - node fs.createWriteStream options
+ * @returns thenable stream, which resolves on stream close
*/
createWriteStream(options?: SecondArgument<typeof createWriteStream>) {
- return createWriteStream(this.path, options);
+ const stream = createWriteStream(this.path, options) as PromiseLikeWriteStream;
+ const promise = new Promise<void>((resolve, reject) => {
+ stream.on('close', () => {
+ resolve();
+ });
+ stream.on('error', err => reject(err));
+ });
+ stream.then = promise.then.bind(promise);
+ return stream;
}
/**
diff --git a/docs/fs-iterable.class.ts.html b/docs/fs-iterable.class.ts.html
index 3a35ae2..8750d96 100644
--- a/docs/fs-iterable.class.ts.html
+++ b/docs/fs-iterable.class.ts.html
@@ -68,7 +68,7 @@
diff --git a/docs/global.html b/docs/global.html
index 5e9966f..c81c32f 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -66,7 +66,7 @@
diff --git a/docs/index.html b/docs/index.html
index af18944..1a1c1c7 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -66,7 +66,7 @@
diff --git a/docs/index.ts.html b/docs/index.ts.html
index 09df2d6..2529208 100644
--- a/docs/index.ts.html
+++ b/docs/index.ts.html
@@ -68,7 +68,7 @@
@@ -197,8 +197,8 @@ index.ts
throw Error(`Not found process.env[${envVariableName}] and fallback value didnt provided.`);
};
/**
- * Returns FSAsyncIterator that
- * takes in a starting index and ending index then iterates
+ * Returns FSAsyncIterator that
+ * takes in a starting index and ending index then iterates
* thru all integers from start to end
* @param from - start index
* @param to - end index