text-pipe / 0.8.0 last updated 2 months ago created on Nov 3rd 2014

Install

npm install --save text-pipe

Clone

git clone git@github.com:wilmoore/text-pipe.git

dependencies show all 15

main stream-reduce 1.0.3 Public Domain
through2-map 1.4.0 MIT
through2-filter 1.4.0 MIT

maintainers

wilmoore wilmoore

versions 8 total

0.8.0 2 months ago wilmoore
0.7.0 2 months ago wilmoore
0.6.0 2 months ago wilmoore
0.5.0 2 months ago wilmoore
0.4.0 2 months ago wilmoore
0.3.0 2 months ago wilmoore
0.2.0 2 months ago wilmoore
0.1.0 2 months ago wilmoore
16 Downloads yesterday.

readme

text-pipe

Transform stream enumeratee generators for stream-driven data extract and transformation (i.e. ETL).

$ npm install text-pipe
text-pipe is a node module that includes functions for creating enumeratees (i.e. map, reduce) that serve as transform streams. This allows you to iteratively compose complex data processing workflows via simple map, reduce, and filter-like functions. Check out the examples folder for working code samples. In order to run the code samples, you must do the following:
1
2
3
4
5
6
% git clone https://github.com/wilmoore/text-pipe.git
% cd text-pipe
% npm install
% cd examples
% cat stackoverflow.txt
% node extract-question-ids
NOTE: read the comments and the code in the examples to get a feel for how it works.

API

.map

aliases: .transform

For each value, return result of calling transformer function to given value.

1
2
3
4
5
var transform = map(function transformer(string) {
  return /\d+/.exec(string)[0];
});

stream.pipe(transform);
.select

aliases: .filter, .keep

For each value, return only values that pass a truth test.

1
2
3
4
5
var transform = select(function (string) {
  return /^question_id:/.exec(string);
});

stream.pipe(transform);
.reduce

aliases: .fold, .inject

Array.prototype.reduce as a through stream.

1
2
3
4
5
var max = reduce(function(memo, val) {
  return Number(val) > Number(memo) ? val : memo;
}, 0)

stream.pipe(max);

Depends on

  • stream-reduce
  • through2-filter: You could use this directly if you want to write {wantStrings: true} boilerplate.
  • through2-map: You could use this directly if you want to write {wantStrings: true} boilerplate.
  • through2: You could use this directly if you want to write write and end boilerplate.

License

MIT

Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.