lesson-task-trasnform 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +20 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,20 @@
1
+ const { Transform } = require("stream");
2
+ const { createReadStream, createWriteStream } = require("fs");
3
+
4
+ const doubleTr = new Transform({
5
+ transform(chunk, encoding, callback) {
6
+ chunk
7
+ .toString()
8
+ .split("")
9
+ .forEach((character) => {
10
+ this.push(character + character);
11
+ });
12
+ callback();
13
+ },
14
+ });
15
+
16
+ module.exports = function doubleFile(nameToRead, nameToWrite) {
17
+ const readStream = createReadStream(nameToRead);
18
+ const writeStream = createWriteStream(nameToWrite);
19
+ readStream.pipe(doubleTr).pipe(writeStream);
20
+ };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "lesson-task-trasnform",
3
+ "version": "1.0.0",
4
+ "description": "transform letters",
5
+ "license": "ISC",
6
+ "author": "KP",
7
+ "type": "commonjs",
8
+ "main": "index.js",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ }
12
+ }