Skip to content

Commit

Permalink
Add more samples and fix split() example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Turcotte committed Dec 4, 2018
1 parent a63f5d3 commit 3776d41
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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
```


Expand Down
6 changes: 6 additions & 0 deletions 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);
11 changes: 4 additions & 7 deletions samples/concat.js
Expand Up @@ -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);
1 change: 1 addition & 0 deletions 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);
5 changes: 5 additions & 0 deletions samples/join.js
@@ -0,0 +1,5 @@
const Mhysa = require("mhysa");

Mhysa.fromArray(["a", "b", "c"])
.pipe(Mhysa.join(","))
.pipe(process.stdout);
14 changes: 4 additions & 10 deletions 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);
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit 3776d41

Please sign in to comment.