diff --git a/README.md b/README.md index e37caa9..c73440b 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Mhysa.fromArray(["a,b", "c,d"]) .pipe(Mhysa.split(",")) .pipe(Mhysa.join("|")) .pipe(process.stdout); -// a|b|c|d is printed out +// a|bc|d is printed out ``` diff --git a/samples/child.js b/samples/child.js new file mode 100644 index 0000000..cde645d --- /dev/null +++ b/samples/child.js @@ -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); diff --git a/samples/concat.js b/samples/concat.js index 7295dcf..1f7104b 100644 --- a/samples/concat.js +++ b/samples/concat.js @@ -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); diff --git a/samples/duplex.js b/samples/duplex.js index 363cd3a..50003c8 100644 --- a/samples/duplex.js +++ b/samples/duplex.js @@ -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); diff --git a/samples/join.js b/samples/join.js new file mode 100644 index 0000000..3c56e8f --- /dev/null +++ b/samples/join.js @@ -0,0 +1,5 @@ +const Mhysa = require("mhysa"); + +Mhysa.fromArray(["a", "b", "c"]) + .pipe(Mhysa.join(",")) + .pipe(process.stdout); diff --git a/samples/split.js b/samples/split.js index 1da1ec4..63dbce7 100644 --- a/samples/split.js +++ b/samples/split.js @@ -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); diff --git a/yarn.lock b/yarn.lock index ede634e..082e22d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2060,7 +2060,7 @@ meow@^5.0.0: yargs-parser "^10.0.0" mhysa@./: - version "1.0.1" + version "1.0.2" micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10"