Pipe take a function

28 views
Skip to first unread message

Ep Ga

unread,
Aug 18, 2014, 7:45:20 AM8/18/14
to nod...@googlegroups.com
And I feel pipe would be so much better if it could except other function that is not native to it but to the ECMAScript spec. I could have done this vie pipe if it was design so. for example:

[code]
```
"use strict";
var num;
num = 1;
process.pipe(function(data){
String(data).split(/\n/).forEach(function(arr){
switch(num){
case (0):{
process.stdout.write(String(arr).toUpperCase()+"\n");
break;
}
case (1):{
process.stdout.write(String(arr).toLowerCase()+"\n");
break;
}
}
if(num === 0){num = 1}else{num = 0}
});
});
```
[/code]

This will make pipe more utilities wise, and easies to use.

Here are two more example:
[code]
```
process.stdin.pipe(function(data){
return (String(data).toUpperCase());
}).pipe(process.stdout);

process.stdin.pipe(function(data){
return (String(data).toLowerCase());
}).pipe(process.stdout);

process.stdin.pipe(function(data){
return ((data).split("\n"));
}).pipe(function(data){
return (function(arr){
(arr).forEach(
function(data){
return (data.charAt[0] % 2 === 0 ?
data.toLowerCase() :
data.toUpperCase());});
}).pipe(process.stdout);
```
[/code]

Floby

unread,
Aug 19, 2014, 4:05:28 AM8/19/14
to nod...@googlegroups.com
What you're looking for already exists without modiyfing the node.js core code.

Reply all
Reply to author
Forward
0 new messages