Convert data to or from Stream
@param  {Object} data                   the data to convert
@param  {'web'|'node'|false} streaming  (optional) whether to return a ReadableStream
@returns {Object}                       the data in the respective format
182593
async function convertStream(data, streaming) {
  if (!streaming && util.isStream(data)) {
    return stream.readToEnd(data);
  }
  if (streaming && !util.isStream(data)) {
    data = new ReadableStream({
      start(controller) {
        controller.enqueue(data);
        controller.close();
      }
    });
  }
  if (streaming === 'node') {
    data = stream.webToNode(data);
  }
  return data;
}
181136
function toBuffer(data, encoding) {
    return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ?
        Buffer.from(data, encoding) : new Buffer(data, encoding);
}
29792
function decodeStream(opts) {
    opts || (opts = {})
    var stream = Transform({ objectMode: true })

    stream._transform = function (data, _, cb) {
      try {
        // decode keys even when keys or values aren't requested specifically
        if ((opts.keys && opts.values) || (!opts.keys && !opts.values)) {
          data.key = ns.decode(data.key, opts)
        }
        else if (opts.keys) {
          data = ns.decode(data, opts)
        }
      }
      catch (err) {
        return cb(err)
      }
      cb(null, data)
    }

    return stream
  }
751564
function streamFromString(string) {
  const s = new stream.Readable();
  s.push(string);
  s.push(null);
  return s;
}
126798
def decode_streaming(self, data):
        
        # Reverse lookup table: map (bitsize, value) to symbols
        lookup = dict(((b, v), s) for (s, (b, v)) in self._table.items())

        buffer = 0
        size = 0
        for byte in data:
            for m in [128, 64, 32, 16, 8, 4, 2, 1]:
                buffer = (buffer << 1) + bool(from_byte(byte) & m)
                size += 1
                if (size, buffer) in lookup:
                    symbol = lookup[size, buffer]
                    if symbol == _EOF:
                        return
                    yield symbol
                    buffer = 0
                    size = 0
95807
function XmlStream(stream, encoding) {
  events.EventEmitter.call(this);
  this._stream = stream;
  this._fa = new FiniteAutomata();
  this._lastState = 0;
  this._startState = {};
  this._finalStates = {};
  this._emitData = false;
  this._bufferLevel = 0;
  this._preserveLevel = 0;
  this._preserveWhitespace = 0;
  this._preserveAll = false;
  this._collect = false;
  this._parser = undefined;

  // Set input stream encoding and create an iconv instance,
  // if conversion is required. Default working encoding is UTF-8,
  // so iconv is used when input is anything else, but UTF-8.
  this._encoding = encoding || null;
  this._encoder = makeEncoder(this._encoding);

  var scope = this;

  // Start parsing.
  process.nextTick(function () {
    parse.call(scope);
  });
}
179962
def data_to_stream(self, data_element, stream):
        
        generator = \
            self._make_representation_generator(stream, self.resource_class,
                                                self._mapping)
        generator.run(data_element)
379702
def dump(data, stream=None, Dumper=Dumper, **kwds):
    
    return dump_all([data], stream, Dumper=Dumper, **kwds)
1244977
public static ObjectStream<Parse> getParseStream(final String inputData)
      throws IOException {
    final ObjectStream<String> parseStream = IOUtils
        .readFileIntoMarkableStreamFactory(inputData);
    final ObjectStream<Parse> samples = new ParseSampleStream(parseStream);
    return samples;
  }
171873
private List<?> convertDataToList(final Object data) {
		if (data == null) {
			return null;
		} else if (data instanceof List) {
			return (List<?>) data;
		} else if (data instanceof Object[]) {
			return Arrays.asList((Object[]) data);
		} else {
			return Arrays.asList(new Object[]{data});
		}
	}
97919
function readFromStream(stream, callback) {
  var buf = [];
  stream.on("data", onData);
  stream.on("end", onEnd);
  stream.on("error", onError);

  function onData(data) {
    buf.push(data);
  }

  function onEnd() {
    if (callback) callback(null, buf.join(""));
    callback = null;
  }

  function onError(err) {
    if (callback) callback(err);
    callback = null;
  }
}
973862
def deserialize(stream_or_string, **options):
    '''
    
    '''

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            return toml.load(stream_or_string, **options)

        if isinstance(stream_or_string, bytes):
            stream_or_string = stream_or_string.decode('utf-8')

        return toml.loads(stream_or_string)
    except Exception as error:
        raise DeserializationError(error)
813680
function(data, cb) {
                if (corbel.Config.isNode) {
                    // in node transform to stream
                    cb(corbel.utils.toURLEncoded(data));
                } else {
                    // in browser transform to blob
                    cb(corbel.utils.dataURItoBlob(data));
                }
            }
1191496
function toStream(input) {
  let streamType = isStream(input);
  if (streamType === 'node') {
    return nodeToWeb(input);
  } else if (streamType) {
    return input;
  }
  return new ReadableStream({
    start(controller) {
      controller.enqueue(input);
      controller.close();
    }
  });
}
552827
function (data) {
      var include = function (path, includeData) {
        var d = utils.shallowCopy({}, data);
        if (includeData) {
          d = utils.shallowCopy(d, includeData);
        }
        var p = includeFile(path, opts)(d);
        return p;
      };
      
      var error = null;
      
      var outputStreamOpts = utils.shallowCopy({}, opts.streamOptions);
      var outputStreamBufferOpts = utils.shallowCopy({}, opts.streamOptions);
      outputStreamBufferOpts.flush = function (cb) {
        cb(error);
      }
      
      var outputStream = new PassThrough(outputStreamOpts);
      var outputStreamBuffer = new PassThrough(outputStreamBufferOpts);
      
      // outputStream.write('');
      outputStream.pipe(outputStreamBuffer);
      
      var p = utils.wrapToPromise(fn, opts.context, Promise, data || {}, escape, include, rethrow, Promise, utils.wrapToPromise, outputStream, Stream);
      
      p.shouldUseBuffer = true;
      p.noBuffer = function () {
        p.outputBuffer = ""
        p.shouldUseBuffer = false;
      }
      p.useBuffer = function () {
        p.shouldUseBuffer = true;
      }
      
      
      // do not continue the script if it is not appropriate to resume writing data to the stream.
      // https://nodejs.org/api/stream.html#stream_event_drain
      p.shouldWaitFlush = false;
      Object.defineProperty(outputStream, 'shouldWaitFlush', {
        get: function () {
          return p.shouldWaitFlush
        },
        set: function (val) {
          p.shouldWaitFlush = val
          return true;
        }
      })
      p.waitFlush = function () {
        p.shouldWaitFlush = true;
      }
      p.noWaitFlush = function () {
        p.shouldWaitFlush = false;
      }
      
      
      p.outputBuffer = ""
      // since the stream got consumed immediatly, we need another stream to buffer it;
      p.outputStream = outputStreamBuffer;
      // a test only property
      p._outputStream = outputStream;
      // since we need to escape the text, and escape only works on string
      outputStream.setEncoding('utf8');
      
      // redirect data to the buffer
      outputStream.on('data', function (data) {
        if (!p.shouldUseBuffer) return;
        p.outputBuffer += data;
      })
      
      // resolve the promise after stream end, so we can get all data.
      outputStream.on('end', function (data) {
        p.defered.resolve(p.outputBuffer)
      })
      
      // hook after generator exit normally
      p.defered.onResolve = function (defered) {
        outputStream.end();
        // force it to flush all buffer since a pipe to fulfilled target prohibit
        // the stream from flushing the data
        // outputStream.uncork();
        
        // use read directly, since uncork sometimes fail to dunp the stream
        while (outputStream.read()) {}
      }
      
      // hook for situation the generator throws
      p.defered.onReject = function (defered, err) {
        // the promise should be reject before stream got end, 
        // or it will cause the stream to think it terminate normally, 
        // since there is not any error event before the end event and promise reject
        defered.reject(err)
        
        // emit only if the user decide to listen to stream's error event instead of promise reject
        // the stream.pipe bind a error listener to stream, so we need to count it
        if (outputStreamBuffer.listenerCount('error') > 1) {
          error = err;
        }
        outputStream.end();
        // force it to flush all buffer since a pipe to fulfilled target prohibit
        // the stream from flushing the data
        // outputStream.uncork();
        
        // use read directly, since uncork sometimes fail to dunp the stream
        while (outputStream.read()) {}
      }
      
      // terminate the stream, prevent further writing
      p.defered.onInterrupt = function (cb) {
        outputStream.end();
        cb();
      }
      
      setTimeout(function() {
        p.execute();
      }, 0)
      return p;
    }
308551
function isReadableStream (stream) {
  return stream !== null
    && typeof (stream) === 'object'
    && typeof (stream.pipe) === 'function'
    && typeof (stream._read) === 'function'
    && typeof (stream._readableState) === 'object'
    && stream.readable !== false
}
293364
function(data) {
		//if (this.debug) console.log("Data: [" + data + "]");
		if (this.echo) process.stdout.write(data);
		this.instream = '' + this.instream + data.toString();

		for (;;) {		// peel off full lines of input containing JSON
			var m = this.instream.match(/\n/);
			if (!m) break;			// no more full lines
			var first_line = this.instream.slice(0, m.index + 1).trim();
			this.instream = this.instream.slice(m.index + 1);

			//if (this.debug) console.log('Line:', [first_line], [this.instream]);

			if (first_line.match(this.prompt)) {
				this.sendReply();
				first_line = first_line.slice(this.promptlength);
				this.instream = first_line + '\n' + this.instream;	// push back command text
				continue;
			}

			if (first_line.charAt(0) == '{') {			// detect JSON update sent by Bitlash
				var json_payload = JSON.parse(first_line);
				//console.log('JSON upstream:', json_payload);
				if (this.json_callback) this.json_callback(json_payload);
			}
			else this.reply.push(first_line);
		}

		// detect prompt indicating last command is complete
		if (this.instream.match(this.prompt)) {
			this.sendReply();
			this.instream = this.instream.slice(this.promptlength);
		}
	}