Add more samples and fix split() example in README

This commit is contained in:
Sami Turcotte
2018-12-04 01:40:46 -05:00
parent a63f5d30ce
commit 3776d41ccd
7 changed files with 22 additions and 19 deletions

6
samples/child.js Normal file
View File

@@ -0,0 +1,6 @@
const Mhysa = require("mhysa");
const catProcess = require("child_process").exec("grep -o ab");
Mhysa.fromArray(["a", "b", "c"])
.pipe(Mhysa.child(catProcess))
.pipe(process.stdout);

View File

@@ -3,13 +3,10 @@ const Mhysa = require("mhysa");
const source1 = new Readable();
const source2 = new Readable();
const expectedElements = ["a", "b", "c", "d"];
let i = 0;
Mhysa.concat(source1, source2).pipe(process.stdout);
source1.push("a");
source2.push("c");
source1.push("b");
source2.push("d");
source1.push("a1 ");
source2.push("c3 ");
source1.push("b2 ");
source2.push("d4 ");
source1.push(null);
source2.push(null);

View File

@@ -1,5 +1,6 @@
const Mhysa = require("mhysa");
const catProcess = require("child_process").exec("grep -o ab");
Mhysa.fromArray(["a", "b", "c"])
.pipe(Mhysa.duplex(catProcess.stdin, catProcess.stdout))
.pipe(process.stdout);

5
samples/join.js Normal file
View File

@@ -0,0 +1,5 @@
const Mhysa = require("mhysa");
Mhysa.fromArray(["a", "b", "c"])
.pipe(Mhysa.join(","))
.pipe(process.stdout);

View File

@@ -1,12 +1,6 @@
const Mhysa = require("mhysa");
const stream = Mhysa.split(",");
const buf = Buffer.from("a,b,c");
stream.on("data", function(data) {
console.log(data);
});
for (let i = 0; i < buf.length; ++i) {
stream.write(buf.slice(i, i + 1));
}
stream.end();
Mhysa.fromArray(["a,b", "c,d"])
.pipe(Mhysa.split(","))
.pipe(Mhysa.join("|"))
.pipe(process.stdout);