diff --git a/README.md b/README.md
index 402031b..9b47b50 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,13 @@
-# Mhysa
+# Strom
**Dependency-free stream utils for Node.js**
-Released under the [MIT](https://github.com/Wenzil/Mhysa/blob/master/LICENSE) license.
+Released under the [MIT](https://git.lewis.id/strom/blob/master/LICENSE) license.
```sh
-yarn add mhysa
+yarn add @jogogo/strom
```
-Tested with Node.js versions 8+
-
## fromArray(array)
Convert an array into a `Readable` stream of its elements
@@ -18,7 +16,7 @@ Convert an array into a `Readable` stream of its elements
| `array` | `T[]` | Array of elements to stream |
```js
-Mhysa.fromArray(["a", "b"])
+strom.fromArray(["a", "b"])
.pipe(process.stdout);
// ab is printed out
```
@@ -35,8 +33,8 @@ Return a `ReadWrite` stream that maps streamed chunks
| `options.writableObjectMode` | `boolean` | Whether this stream should behave as a writable stream of objects |
```js
-Mhysa.fromArray(["a", "b"])
- .pipe(Mhysa.map(s => s.toUpperCase()))
+strom.fromArray(["a", "b"])
+ .pipe(strom.map(s => s.toUpperCase()))
.pipe(process.stdout);
// AB is printed out
```
@@ -53,8 +51,8 @@ Return a `ReadWrite` stream that flat maps streamed chunks
| `options.writableObjectMode` | `boolean` | Whether this stream should behave as a writable stream of objects |
```js
-Mhysa.fromArray(["a", "AA"])
- .pipe(Mhysa.flatMap(s => new Array(s.length).fill(s)))
+strom.fromArray(["a", "AA"])
+ .pipe(strom.flatMap(s => new Array(s.length).fill(s)))
.pipe(process.stdout);
// aAAAA is printed out
```
@@ -70,8 +68,8 @@ Return a `ReadWrite` stream that filters out streamed chunks for which the predi
| `options.objectMode` | `boolean` | `boolean` | Whether this stream should behave as a stream of objects |
```js
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.filter(s => s !== "b"))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.filter(s => s !== "b"))
.pipe(process.stdout);
// ac is printed out
```
@@ -90,9 +88,9 @@ value
| `options.writableObjectMode` | `boolean` | Whether this stream should behave as a writable stream of objects |
```js
-Mhysa.fromArray(["a", "b", "cc"])
- .pipe(Mhysa.reduce((acc, s) => ({ ...acc, [s]: s.length }), {}))
- .pipe(Mhysa.stringify())
+strom.fromArray(["a", "b", "cc"])
+ .pipe(strom.reduce((acc, s) => ({ ...acc, [s]: s.length }), {}))
+ .pipe(strom.stringify())
.pipe(process.stdout);
// {"a":1,"b":1","c":2} is printed out
```
@@ -108,9 +106,9 @@ Return a `ReadWrite` stream that splits streamed chunks using the given separato
| `options.encoding` | `string` | Character encoding to use for decoding chunks. Defaults to utf8
```js
-Mhysa.fromArray(["a,b", "c,d"])
- .pipe(Mhysa.split(","))
- .pipe(Mhysa.join("|"))
+strom.fromArray(["a,b", "c,d"])
+ .pipe(strom.split(","))
+ .pipe(strom.join("|"))
.pipe(process.stdout);
// a|bc|d is printed out
```
@@ -126,8 +124,8 @@ Return a `ReadWrite` stream that joins streamed chunks using the given separator
| `options.encoding` | `string` | Character encoding to use for decoding chunks. Defaults to utf8
```js
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.join(","))
.pipe(process.stdout);
// a,b,c is printed out
```
@@ -145,8 +143,8 @@ the streamed chunks with the specified replacement string
| `options.encoding` | `string` | Character encoding to use for decoding chunks. Defaults to utf8
```js
-Mhysa.fromArray(["a1", "b22", "c333"])
- .pipe(Mhysa.replace(/b\d+/, "B"))
+strom.fromArray(["a1", "b22", "c333"])
+ .pipe(strom.replace(/b\d+/, "B"))
.pipe(process.stdout);
// a1Bc333 is printed out
```
@@ -156,8 +154,8 @@ Mhysa.fromArray(["a1", "b22", "c333"])
Return a `ReadWrite` stream that parses the streamed chunks as JSON
```js
-Mhysa.fromArray(['{ "a": "b" }'])
- .pipe(Mhysa.parse())
+strom.fromArray(['{ "a": "b" }'])
+ .pipe(strom.parse())
.once("data", object => console.log(object));
// { a: 'b' } is printed out
```
@@ -167,8 +165,8 @@ Mhysa.fromArray(['{ "a": "b" }'])
Return a `ReadWrite` stream that stringifies the streamed chunks to JSON
```js
-Mhysa.fromArray([{ a: "b" }])
- .pipe(Mhysa.stringify())
+strom.fromArray([{ a: "b" }])
+ .pipe(strom.stringify())
.pipe(process.stdout);
// {"a":"b"} is printed out
```
@@ -183,8 +181,8 @@ Return a `ReadWrite` stream that collects streamed chunks into an array or buffe
| `options.objectMode` | `boolean` | Whether this stream should behave as a stream of objects |
```js
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.collect({ objectMode: true }))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.collect({ objectMode: true }))
.once("data", object => console.log(object));
// [ 'a', 'b', 'c' ] is printed out
```
@@ -200,7 +198,7 @@ Return a `Readable` stream of readable streams concatenated together
```js
const source1 = new Readable();
const source2 = new Readable();
-Mhysa.concat(source1, source2).pipe(process.stdout)
+strom.concat(source1, source2).pipe(process.stdout)
source1.push("a1 ");
source2.push("c3 ");
source1.push("b2 ");
@@ -221,7 +219,7 @@ Return a `Readable` stream of readable streams merged together in chunk arrival
```js
const source1 = new Readable({ read() {} });
const source2 = new Readable({ read() {} });
-Mhysa.merge(source1, source2).pipe(process.stdout);
+strom.merge(source1, source2).pipe(process.stdout);
source1.push("a1 ");
setTimeout(() => source2.push("c3 "), 10);
setTimeout(() => source1.push("b2 "), 20);
@@ -243,8 +241,8 @@ cause the given readable stream to yield chunks
```js
const catProcess = require("child_process").exec("grep -o ab");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.duplex(catProcess.stdin, catProcess.stdout))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.duplex(catProcess.stdin, catProcess.stdout))
.pipe(process.stdout);
// ab is printed out
```
@@ -259,8 +257,8 @@ Return a `Duplex` stream from a child process' stdin and stdout
```js
const catProcess = require("child_process").exec("grep -o ab");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.child(catProcess))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.child(catProcess))
.pipe(process.stdout);
// ab is printed out
```
@@ -276,8 +274,8 @@ ended
```js
let f = async () => {
- const source = Mhysa.fromArray(["a", "b", "c"]);
- console.log(await Mhysa.last(source));
+ const source = strom.fromArray(["a", "b", "c"]);
+ console.log(await strom.last(source));
};
f();
// c is printed out
diff --git a/package.json b/package.json
index f7068f3..2b12f8d 100644
--- a/package.json
+++ b/package.json
@@ -1,17 +1,16 @@
{
- "name": "@jogogo/mhysa",
- "version": "2.0.0-alpha.4",
- "description": "Streams and event emitter utils for Node.js",
+ "name": "strom",
+ "version": "2.0.0",
+ "description": "Streams utils for Node.js",
"keywords": [
"promise",
"stream",
- "event emitter",
"utils"
],
- "author": {
- "name": "Wenzil"
- },
"contributors": [
+ {
+ "name": "Wenzil"
+ },
{
"name": "jerry",
"email": "jerry@jogogo.co"
@@ -27,11 +26,8 @@
"files": [
"dist"
],
- "publishConfig": {
- "registry": "https://npm.dev.jogogo.co/"
- },
"repository": {
- "url": "git@github.com:Jogogoplay/mhysa.git",
+ "url": "git@git.lewis.id:ldiamond/strom.git",
"type": "git"
},
"scripts": {
diff --git a/samples/async.js b/samples/async.js
index 0f833b0..e897836 100644
--- a/samples/async.js
+++ b/samples/async.js
@@ -1,8 +1,8 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.map(s => Promise.resolve(s + s)))
- .pipe(Mhysa.flatMap(s => Promise.resolve([s, s.toUpperCase()])))
- .pipe(Mhysa.filter(s => Promise.resolve(s !== "bb")))
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.map(s => Promise.resolve(s + s)))
+ .pipe(strom.flatMap(s => Promise.resolve([s, s.toUpperCase()])))
+ .pipe(strom.filter(s => Promise.resolve(s !== "bb")))
+ .pipe(strom.join(","))
.pipe(process.stdout);
diff --git a/samples/child.js b/samples/child.js
index cde645d..aa1d8e3 100644
--- a/samples/child.js
+++ b/samples/child.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
const catProcess = require("child_process").exec("grep -o ab");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.child(catProcess))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.child(catProcess))
.pipe(process.stdout);
diff --git a/samples/collect.js b/samples/collect.js
index 0e48e9f..a1d43cd 100644
--- a/samples/collect.js
+++ b/samples/collect.js
@@ -1,5 +1,5 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.collect({ objectMode: true }))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.collect({ objectMode: true }))
.on("data", object => console.log(object));
diff --git a/samples/concat.js b/samples/concat.js
index 1f7104b..17c5367 100644
--- a/samples/concat.js
+++ b/samples/concat.js
@@ -1,9 +1,9 @@
const { Readable } = require("stream");
-const Mhysa = require("mhysa");
+const strom = require("strom");
const source1 = new Readable();
const source2 = new Readable();
-Mhysa.concat(source1, source2).pipe(process.stdout);
+strom.concat(source1, source2).pipe(process.stdout);
source1.push("a1 ");
source2.push("c3 ");
source1.push("b2 ");
diff --git a/samples/duplex.js b/samples/duplex.js
index 50003c8..6af834b 100644
--- a/samples/duplex.js
+++ b/samples/duplex.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
const catProcess = require("child_process").exec("grep -o ab");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.duplex(catProcess.stdin, catProcess.stdout))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.duplex(catProcess.stdin, catProcess.stdout))
.pipe(process.stdout);
diff --git a/samples/filter.js b/samples/filter.js
index f9aeda1..78d1981 100644
--- a/samples/filter.js
+++ b/samples/filter.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.filter(s => s !== "b"))
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.filter(s => s !== "b"))
+ .pipe(strom.join(","))
.pipe(process.stdout);
diff --git a/samples/flatMap.js b/samples/flatMap.js
index 695dd5c..f9b8ab9 100644
--- a/samples/flatMap.js
+++ b/samples/flatMap.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "AA"])
- .pipe(Mhysa.flatMap(s => new Array(s.length).fill(s)))
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "AA"])
+ .pipe(strom.flatMap(s => new Array(s.length).fill(s)))
+ .pipe(strom.join(","))
.pipe(process.stdout);
diff --git a/samples/join.js b/samples/join.js
index 3c56e8f..1b57833 100644
--- a/samples/join.js
+++ b/samples/join.js
@@ -1,5 +1,5 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b", "c"])
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "b", "c"])
+ .pipe(strom.join(","))
.pipe(process.stdout);
diff --git a/samples/last.js b/samples/last.js
index eb74c9c..b508dbf 100644
--- a/samples/last.js
+++ b/samples/last.js
@@ -1,7 +1,7 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
let f = async () => {
- const source = Mhysa.fromArray(["a", "b", "c"]);
- console.log(await Mhysa.last(source));
+ const source = strom.fromArray(["a", "b", "c"]);
+ console.log(await strom.last(source));
};
f();
diff --git a/samples/map.js b/samples/map.js
index 7dc8142..54848c2 100644
--- a/samples/map.js
+++ b/samples/map.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b"])
- .pipe(Mhysa.map(s => s.toUpperCase()))
- .pipe(Mhysa.join(","))
+strom.fromArray(["a", "b"])
+ .pipe(strom.map(s => s.toUpperCase()))
+ .pipe(strom.join(","))
.pipe(process.stdout);
diff --git a/samples/merge.js b/samples/merge.js
index bb7b1e9..d2fb028 100644
--- a/samples/merge.js
+++ b/samples/merge.js
@@ -1,9 +1,9 @@
const { Readable } = require("stream");
-const Mhysa = require("mhysa");
+const strom = require("strom");
const source1 = new Readable({ read() {} });
const source2 = new Readable({ read() {} });
-Mhysa.merge(source1, source2).pipe(process.stdout);
+strom.merge(source1, source2).pipe(process.stdout);
source1.push("a1 ");
setTimeout(() => source2.push("c3 "), 10);
setTimeout(() => source1.push("b2 "), 20);
diff --git a/samples/parse.js b/samples/parse.js
index 791ed56..3916cd3 100644
--- a/samples/parse.js
+++ b/samples/parse.js
@@ -1,5 +1,5 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(['{ "a": "b" }'])
- .pipe(Mhysa.parse())
+strom.fromArray(['{ "a": "b" }'])
+ .pipe(strom.parse())
.on("data", object => console.log(object));
diff --git a/samples/reduce.js b/samples/reduce.js
index 77e039c..7b62038 100644
--- a/samples/reduce.js
+++ b/samples/reduce.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a", "b", "cc"])
- .pipe(Mhysa.reduce((acc, s) => ({ ...acc, [s]: s.length }), {}))
- .pipe(Mhysa.stringify())
+strom.fromArray(["a", "b", "cc"])
+ .pipe(strom.reduce((acc, s) => ({ ...acc, [s]: s.length }), {}))
+ .pipe(strom.stringify())
.pipe(process.stdout);
diff --git a/samples/replace.js b/samples/replace.js
index f0ab201..1df484c 100644
--- a/samples/replace.js
+++ b/samples/replace.js
@@ -1,5 +1,5 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a1", "b22", "c333"])
- .pipe(Mhysa.replace(/b\d+/, "B"))
+strom.fromArray(["a1", "b22", "c333"])
+ .pipe(strom.replace(/b\d+/, "B"))
.pipe(process.stdout);
diff --git a/samples/split.js b/samples/split.js
index 63dbce7..24c005b 100644
--- a/samples/split.js
+++ b/samples/split.js
@@ -1,6 +1,6 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray(["a,b", "c,d"])
- .pipe(Mhysa.split(","))
- .pipe(Mhysa.join("|"))
+strom.fromArray(["a,b", "c,d"])
+ .pipe(strom.split(","))
+ .pipe(strom.join("|"))
.pipe(process.stdout);
diff --git a/samples/stringify.js b/samples/stringify.js
index a3ae7be..e7c5f35 100644
--- a/samples/stringify.js
+++ b/samples/stringify.js
@@ -1,5 +1,5 @@
-const Mhysa = require("mhysa");
+const strom = require("strom");
-Mhysa.fromArray([{ a: "b" }])
- .pipe(Mhysa.stringify())
+strom.fromArray([{ a: "b" }])
+ .pipe(strom.stringify())
.pipe(process.stdout);
diff --git a/src/functions/index.ts b/src/functions/index.ts
index de61d44..7ffd8d0 100644
--- a/src/functions/index.ts
+++ b/src/functions/index.ts
@@ -28,7 +28,7 @@ import { unbatch } from "./unbatch";
import { compose } from "./compose";
import { demux } from "./demux";
-export default function mhysa(defaultOptions?: TransformOptions) {
+export default function strom(defaultOptions?: TransformOptions) {
function withDefaultOptions(
n: number,
fn: (...args: T) => R,