You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
793 B
JavaScript

"use strict";
const Promise = require("bluebird");
const path = require("path");
const errorChain = require("error-chain");
const pipe = require("@promistream/pipe");
const fromNodeStream = require("@promistream/from-node-stream");
const map = require("@promistream/map");
const join = require("@promistream/join");
const splitLines = require("@promistream/split-lines");
const decodeString = require("@promistream/decode-string");
const readFile = require("./");
return Promise.try(() => {
return pipe([
readFile(path.join(__dirname, "example.js")),
decodeString("utf8"),
splitLines(),
map((line) => line.trim()),
join("\n"),
fromNodeStream(process.stdout)
]).read();
}).then(() => {
console.log("Done!");
}).catch((error) => {
console.error(errorChain.render(error));
});