/* jshint -W078 */

'use strict';

let stream = require('stream');

function BidiTransform(options) {
  this._clientToServer = new stream.Transform();
  this._serverToClient = new stream.Transform();

  if (options.client) {
    this.clientEndState = options.client;
  }
  if (options.server) {
    this.serverEndState = options.server;
  }
}

BidiTransform.prototype = {

  get to() {
    return {
      client: this._serverToClient,
      server: this._clientToServer
    };
  },

  get from() {
    return {
      client: this._clientToServer,
      server: this._serverToClient
    };
  },

  set clientEndState(options) {
    for (let option in options) {
      this._clientToServer._writableState[option] = options[option];
      this._serverToClient._readableState[option] = options[option];
    }
  },

  set serverEndState(options) {
    for (let option in options) {
      this._clientToServer._readableState[option] = options[option];
      this._serverToClient._writableState[option] = options[option];
    }
  }

};

module.exports = BidiTransform;

@@ -103,30 +103,34 @@
   this._
-clientToServer
+externalToInternal
  = new s
@@ -156,30 +156,34 @@
   this._
-serverToClient
+internalToExternal
  = new s
@@ -216,22 +216,24 @@
 options.
-client
+external
 ) %7B%0A    
@@ -237,25 +237,24 @@
    this.
-clientEnd
+external
 State = 
@@ -261,22 +261,24 @@
 options.
-client
+external
 ;%0A  %7D%0A  
@@ -289,22 +289,24 @@
 options.
-server
+internal
 ) %7B%0A    
@@ -310,25 +310,24 @@
    this.
-serverEnd
+internal
 State = 
@@ -334,22 +334,24 @@
 options.
-server
+internal
 ;%0A  %7D%0A%7D%0A
@@ -416,184 +416,208 @@
     
-client: this._serverToClient,%0A      server: this._clientToServer%0A    %7D;%0A  %7D,%0A%0A  get from() %7B%0A    return %7B%0A      client: this._clientToServer,%0A      server: this._serverToClient
+external: this._internalToExternal,%0A      internal: this._externalToInternal%0A    %7D;%0A  %7D,%0A%0A  get from() %7B%0A    return %7B%0A      external: this._externalToInternal,%0A      internal: this._internalToExternal
 %0A   
@@ -636,17 +636,16 @@
 set 
-clientEnd
+external
 Stat
@@ -703,30 +703,34 @@
   this._
-clientToServer
+externalToInternal
 ._writab
@@ -776,30 +776,34 @@
   this._
-serverToClient
+internalToExternal
 ._readab
@@ -859,17 +859,16 @@
 set 
-serverEnd
+internal
 Stat
@@ -930,22 +930,26 @@
 is._
-clientToServer
+externalToInternal
 ._re
@@ -1003,22 +1003,26 @@
 is._
-serverToClient
+internalToExternal
 ._wr

Rename to internal / external