Add more samples and fix split() example in README
This commit is contained in:
parent
a63f5d30ce
commit
3776d41ccd
@ -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
|
||||
```
|
||||
|
||||
|
||||
|
6
samples/child.js
Normal file
6
samples/child.js
Normal 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);
|
@ -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,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
5
samples/join.js
Normal file
@ -0,0 +1,5 @@
|
||||
const Mhysa = require("mhysa");
|
||||
|
||||
Mhysa.fromArray(["a", "b", "c"])
|
||||
.pipe(Mhysa.join(","))
|
||||
.pipe(process.stdout);
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user