Well, this is possible too:

```js
var data = '';
function withPipe(data) {
   console.log('content was piped');
   console.log(data.trim());
}
function withoutPipe() {
   console.log('no content was piped');
}

var self = process.stdin;
self.on('readable', function() {
    var chunk = this.read();
    if (chunk == null) { // ←←←←←←←←
        withoutPipe();
    } else {
       data += chunk;
    }
});
self.on('end', function() {
   withPipe(data);
});
```

Depending on whether it’s a TTY or not, it will call `withoutPipe()` or `withPipe()`. But this check is not synchronous.