Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created October 17, 2015 03:29
Show Gist options
  • Save ajcrites/41851dda3b05e33f0897 to your computer and use it in GitHub Desktop.
Save ajcrites/41851dda3b05e33f0897 to your computer and use it in GitHub Desktop.
let highland = require("highland");
let Transform = require("stream").Transform;
let byline = require("byline");
class AsyncTransformStream extends Transform {
_transform(chunk, encoding, callback) {
setImmediate(() => {
this.push(chunk + "\n");
callback();
});
}
}
highland(byline(process.stdin, {encoding: "utf8"}))
.map(value => value.trim())
.pipe(new AsyncTransformStream)
.pipe(process.stdout);
let highland = require("highland");
let Transform = require("stream").Transform;
let byline = require("byline");
let trimAttributes = highland().map(value => value.trim());
class AsyncTransformStream extends Transform {
_transform(chunk, encoding, callback) {
setImmediate(() => {
this.push(chunk + "\n");
callback();
});
}
}
byline(process.stdin, {encoding: "utf8"})
.pipe(trimAttributes)
.pipe(new AsyncTransformStream)
.pipe(process.stdout);
{
"name": "highland-experiment",
"version": "1.0.0",
"description": "",
"main": "correct-highland.js",
"dependencies": {
"byline": "^4.2.1",
"highland": "^2.5.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment