lessontask 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.
- package/index.js +25 -0
- package/package.json +12 -0
- package/result.txt +1 -0
- package/test.txt +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const {createReadStream, createWriteStream} = require("fs")
|
|
2
|
+
const { Transform } = require("stream");
|
|
3
|
+
|
|
4
|
+
const transformStream = new Transform({
|
|
5
|
+
transform(chunk, encoding, callback){
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let raw = chunk.toString()
|
|
9
|
+
let edited = ""
|
|
10
|
+
for(const char of raw){
|
|
11
|
+
edited = edited + char + char
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
this.push(edited)
|
|
15
|
+
callback()
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
module.exports = function doubleFile(inputFile, outputFile){
|
|
21
|
+
const readStream = createReadStream(inputFile);
|
|
22
|
+
const writeStream = createWriteStream(outputFile);
|
|
23
|
+
|
|
24
|
+
readStream.pipe(transformStream).pipe(writeStream)
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lessontask",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "function for taking a file, converting every char x2 and saving output file",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
}
|
|
12
|
+
}
|
package/result.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
HHii,, II aamm JJoohhnn DDooee!!
|
package/test.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hi, I am John Doe!
|