fake Writable stream to collect the data into a string
482590
function toStr(next) {
          var stream = new Writable();
          var str = "";
          stream.write = function(chunk) {
              str += (chunk);
          };
          stream.end = function() {
              next(str);
          };
          return stream;
        }
390965
function getTTYStream(stream: UnderlyingStream): ?tty.WriteStream {
  if (
    stream instanceof tty.WriteStream &&
    stream.isTTY &&
    stream.columns >= 1
  ) {
    return stream;
  }
  return null;
}
270960
def to_string_io
      content = StringIO.new
      while bytes = read and !bytes.empty?
        content.write( bytes )
      end
      content.rewind
      content
    end
1064068
def wrap_as_stream(item):
    
    if not PY3:
        return StringIO(item)
    if isinstance(item, str):
        return StringIO(item)
    elif isinstance(item, bytes):
        return BytesIO(item)
    raise ValueError('{} is not wrappable!'.format(type(item).__name__))
949876
def read_stream (stream):
    """"""

    section = None
    key = None
    data = None

    for fullline in stream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New section
            if section is not None:
                if key is not None:
                    section.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield section

            section = Holder ()
            section.section = m.group (1)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            continue

        m = escre.match (fullline)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            section.set_one (key, data.decode ('utf8'))
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not len (data):
                data = ' '
            elif not data[-1].isspace ():
                data += ' '
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if section is not None:
        if key is not None:
            section.set_one (key, data.strip ().decode ('utf8'))
        yield section
1348415
def _write_txt(self, stream):
        '''
        

        '''
        for rec in self.data:
            fields = []
            for prop in self.properties:
                fields.extend(prop._to_fields(rec[prop.name]))

            _np.savetxt(stream, [fields], '%.18g', newline='\n')
1314092
function stream(out, err) {
  if(!err) err = out;

  if(typeof out === 'string') {
    this._out = fs.createWriteStream(out);
  }else{
    this._out = out;
  }

  if(typeof err === 'string') {
    this._err = fs.createWriteStream(err);
  }else{
    this._err = err;
  }

  if((!(this._out instanceof Writable)
      && this._out !== process.stdout)
    || (!(this._err instanceof Writable)
      && this._err !== process.stderr)) {
    throw new Error('invalid log stream');
  }
}
355070
function(input, output, literal, cb) {
  var text = '';
  input.on ('data', function gatherer (data) {
    text += '' + data;   // Converting to UTF-8 string.
  });
  input.on ('end', function writer () {
    try {
      var write = function(data) { output.write(data); };
      template(text)(write, literal);
    } catch (e) {
      if (cb) { cb (e); }
    } finally {
      // There are streams you cannot end.
      try {
        output.end ();
      } catch (e) {} finally {
        if (cb) { cb (null); }
      }
    }
  });
}
1049068
def dump(self, **kwargs):
    """"""

    f = io.StringIO()
    w = Writer(f, self.keys, **kwargs)
    w.write(self)
    text = f.getvalue().lstrip()
    f.close()

    return text
228212
public void rawWrite(Object array, int byteOffset, int byteLength)
            throws IOException
    {
        if (closed) {
            throw new IOException("Stream is closed");
        }
        int cursor = 0;
        while (cursor < byteLength) {
            int readLen = Math.min(byteLength - cursor, blockSize - inputCursor);
            // copy the input data to uncompressed buffer
            if (readLen > 0) {
                Snappy.arrayCopy(array, byteOffset + cursor, readLen, inputBuffer, inputCursor);
                inputCursor += readLen;
            }
            if (inputCursor < blockSize) {
                return;
            }

            compressInput();
            cursor += readLen;
        }
    }
290005
def encode_str(s, mutable=False):
    """"""
    rv = ffi.new("SemaphoreStr *")
    if isinstance(s, text_type):
        s = s.encode("utf-8")
    if mutable:
        s = bytearray(s)
    rv.data = ffi.from_buffer(s)
    rv.len = len(s)
    # we have to hold a weak reference here to ensure our string does not
    # get collected before the string is used.
    attached_refs[rv] = s
    return rv
240040
function gotData() {
  var currentString = serial.readLine();  // read the incoming string
  trim(currentString);                    // remove any trailing whitespace
  if (!currentString) return;             // if the string is empty, do no more
  console.log(currentString);             // println the string
  latestData = currentString;            // save it for the draw method
}
723995
def format(self, obj, **kwargs):
        """"""
        sio = StringIO()
        self.fprint(obj, stream=sio, **kwargs)
        return sio.getvalue()
653220
def parse_stream_raw(self, stream, debug=False):
        """"""
        tokens = tokenize.generate_tokens(stream.readline)
        return self.parse_tokens(tokens, debug)
386359
def get(self, stream, fmt='txt', **kwargs):
        """"""
        sel = ''.join(["&{0}={1}".format(k, v) for (k, v) in kwargs.items()])
        url = "streamds/{0}.{1}?{2}".format(stream, fmt, sel[1:])
        data = self._db._get_content(url)
        if not data:
            log.error("No data found at URL '%s'." % url)
            return
        if (data.startswith("ERROR")):
            log.error(data)
            return
        if fmt == "txt":
            return read_csv(data)
        return data
356419
function streamToText(stream) {
    return new Promise((fulfill, reject) => {
        let chunks = [];
        let length = 0;
        stream.setEncoding('utf8');
        stream.on('data', chunk => {
            length += chunk.length;
            if (length > MAX_TEXT_LENGTH) {
                reject(new Error('Response is too big'));
                return;
            }
            chunks.push(chunk);
        });
        stream.on('end', () => {
            fulfill(chunks.join(''));
        });
        stream.on('error', err => {
            reject(err);
        });
    });
}
750824
def to_string(self, obj):
        
        stream = NativeIO()
        self.to_stream(obj, stream)
        return text_(stream.getvalue(), encoding=self.encoding)