diff --git a/README.md b/README.md index 3e6552b..655c9a4 100644 --- a/README.md +++ b/README.md @@ -14,25 +14,27 @@ The following snippet demonstrates most of Mhysa's current features without much will come! ```js -const { sleep, once, delay, stream } = require("mhysa"); +const { + utils: { sleep, delay, once }, + ...Mhysa +} = require("mhysa"); async function main() { - const collector = stream - .concat( - stream.fromArray(["a\n", "b\n", "c\n"]), - stream.fromArray(["d", "e"]).pipe(stream.join("-")), - ) - .pipe(stream.split("\n")) + const collector = Mhysa.concat( + Mhysa.fromArray(["a\n", "b\n", "c\n"]), + Mhysa.fromArray(["d", "e"]).pipe(Mhysa.join("-")), + ) + .pipe(Mhysa.split("\n")) .pipe( - stream.flatMap(async s => { + Mhysa.flatMap(async s => { await sleep(100); return delay([s, s.toUpperCase()], 100); }), ) - .pipe(stream.collect({ objectMode: true })); + .pipe(Mhysa.collect({ objectMode: true })); const collected = await once(collector, "data"); - console.log(collected); // [ 'a', 'A', 'b', 'B', 'c', 'C', 'd-e', 'D-E' ] (after 12 * 100 ms) + console.log(collected); // [ 'a', 'A', 'b', 'B', 'c', 'C', 'd-e', 'D-E' ] (after 6 * 100 ms) } main(); ``` @@ -118,7 +120,7 @@ export declare function concat( ): NodeJS.ReadableStream; ``` -### mhysa +### { utils } ```ts /** diff --git a/package.json b/package.json index 3918c52..c50c96a 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@types/node": "^10.12.10", "ava": "^1.0.0-rc.2", "chai": "^4.2.0", - "mhysa": ".", + "mhysa": "./", "prettier": "^1.14.3", "ts-node": "^7.0.1", "tslint": "^5.11.0", diff --git a/samples/concat_files.js b/samples/concat_files.js index 3b26a24..871ecba 100644 --- a/samples/concat_files.js +++ b/samples/concat_files.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const { stream } = require("mhysa"); +const Mhysa = require("mhysa"); const sourceFile1 = path.join(process.cwd(), "package.json"); const sourceFile2 = path.join(process.cwd(), "README.md"); @@ -12,10 +12,8 @@ if (!fs.existsSync(outputDir)) { } // Concat two source files together into one -stream - .concat( - fs.createReadStream(sourceFile1), - stream.fromArray(["\n"]), - fs.createReadStream(sourceFile2), - ) - .pipe(fs.createWriteStream(outputFile)); +Mhysa.concat( + fs.createReadStream(sourceFile1), + Mhysa.fromArray(["\n"]), + fs.createReadStream(sourceFile2), +).pipe(fs.createWriteStream(outputFile)); diff --git a/samples/demo.js b/samples/demo.js index 4bfbb3e..c874fe0 100644 --- a/samples/demo.js +++ b/samples/demo.js @@ -1,19 +1,21 @@ -const { sleep, once, delay, stream } = require("mhysa"); +const { + utils: { sleep, delay, once }, + ...Mhysa +} = require("mhysa"); async function main() { - const collector = stream - .concat( - stream.fromArray(["a\n", "b\n", "c\n"]), - stream.fromArray(["d", "e"]).pipe(stream.join("-")), - ) - .pipe(stream.split("\n")) + const collector = Mhysa.concat( + Mhysa.fromArray(["a\n", "b\n", "c\n"]), + Mhysa.fromArray(["d", "e"]).pipe(Mhysa.join("-")), + ) + .pipe(Mhysa.split("\n")) .pipe( - stream.flatMap(async s => { + Mhysa.flatMap(async s => { await sleep(100); return delay([s, s.toUpperCase()], 100); }), ) - .pipe(stream.collect({ objectMode: true })); + .pipe(Mhysa.collect({ objectMode: true })); const collected = await once(collector, "data"); console.log(collected); // [ 'a', 'A', 'b', 'B', 'c', 'C', 'd-e', 'D-E' ] (after 6 * 100 ms) diff --git a/src/index.ts b/src/index.ts index 0fa8b50..ac82103 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import * as utils from "./utils"; import * as stream from "./stream"; export = { - ...utils, - stream, + utils, + ...stream, }; diff --git a/yarn.lock b/yarn.lock index 706f17b..9e4d17f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2066,8 +2066,8 @@ meow@^5.0.0: trim-newlines "^2.0.0" yargs-parser "^10.0.0" -mhysa@.: - version "0.4.1" +mhysa@./: + version "0.5.0-beta.0" micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10"