Add new incoming data to buffer and try to process
554703
def feed(self, data):
        
        self.buffer += data
        while len(self.buffer) >= 6:
            self.next_packet()
298059
function processInput(buffer, cb) {
    if (buffer.length == 0) return buffer;
    var split_char = '\n';
    var lines = buffer.split(split_char);
    // If there are any line splits, the below logic always works, but if there are none we need to detect this and skip
    // any processing.
    if (lines[0].length == buffer.length) return buffer;
    // Note last item is ignored since it is the remainder (or empty)
    for(var i = 0; i < lines.length-1; i++) {
        var line = lines[i];
        if (format == "binary") {
            target.produce(line, handleProduceResponse.bind(undefined, cb));
        } else if (format == "avro") {
            // Avro data should be passed in its JSON-serialized form
            try {
                var avro = JSON.parse(line);
            } catch (e) {
                console.log("Couldn't parse '" + line + "' as JSON");
                continue;
            }
            target.produce(valueSchema, avro, handleProduceResponse.bind(undefined, cb));
        }
        // OR with key or partition:
        //target.produce({'partition': 0, 'value': line}, handleProduceResponse.bind(undefined, cb));
        //target.produce({'key': 'console', 'value': line}, handleProduceResponse.bind(undefined, cb));
        num_messages += 1;
        num_bytes += line.length;
    }
    return lines[lines.length-1];
}
1139055
def insertData(self, offset: int, string: str) -> None:
        """"""
        self._insert_data(offset, string)
124257
def append(self, data: Union[bytes, bytearray, memoryview]) -> None:
        
        size = len(data)
        if size > self._large_buf_threshold:
            if not isinstance(data, memoryview):
                data = memoryview(data)
            self._buffers.append((True, data))
        elif size > 0:
            if self._buffers:
                is_memview, b = self._buffers[-1]
                new_buf = is_memview or len(b) >= self._large_buf_threshold
            else:
                new_buf = True
            if new_buf:
                self._buffers.append((False, bytearray(data)))
            else:
                b += data  # type: ignore

        self._size += size
71807
static void fillBufferFrom(InputStream in, byte[] buf, int offset, int len)
            throws IOException
    {
        for (int read = 0; len > 0; len -= read, offset += read)
        {
            read = in.read(buf, offset, len);
            if (read == -1)
                throw ProtobufException.truncatedMessage();
        }
    }
1232852
def push(self, len, buf):
        
        ret = libxml2mod.xmlParserInputBufferPush(self._o, len, buf)
        return ret
1215723
private void dataBufferAppend(char[] ch, int start, int length) {
        dataBuffer = (char[]) extendArray(dataBuffer, dataBuffer.length,
                dataBufferPos + length);

        System.arraycopy(ch, start, dataBuffer, dataBufferPos, length);
        dataBufferPos += length;
    }
124367
private void refill() throws IOException {
        if (eof) return;
        int bytesRead = in.read(inputBuffer);
        boolean success;
        if (bytesRead == -1) {
            eof = true;
            success = coder.process(EMPTY, 0, 0, true);
        } else {
            success = coder.process(inputBuffer, 0, bytesRead, false);
        }
        if (!success) {
            throw new Base64DataException("bad base-64");
        }
        outputEnd = coder.op;
        outputStart = 0;
    }
507178
def push(self, buf):
        
        self._src.emit('push-buffer', Gst.Buffer.new_wrapped(buf))
322295
def process_data(self):
        ""

        try:
            reader = getattr(self.socket, 'read', self.socket.recv)
            new_data = reader(2 ** 14)
        except socket.error:
            # The server hung up.
            self.disconnect("Connection reset by peer")
            return
        if not new_data:
            # Read nothing: connection must be down.
            self.disconnect("Connection reset by peer")
            return

        self.buffer.feed(new_data)

        # process each non-empty line after logging all lines
        for line in self.buffer:
            log.debug("FROM SERVER: %s", line)
            if not line:
                continue
            self._process_line(line)
1358877
def append_data(self, data_buffer):
        

        if len(data_buffer) % (self.sample_width * self.channels) != 0:
            raise ValueError("length of data_buffer must be a multiple of (sample_width * channels)")

        self._buffer += data_buffer
        self._left += len(data_buffer)
1022938
public void put(int data)
    {
        // If the buffer is small.
        if (mBuffer.capacity() < (mLength + 1))
        {
            expandBuffer(mLength + ADDITIONAL_BUFFER_SIZE);
        }

        mBuffer.put((byte)data);
        ++mLength;
    }
420718
def _process(self, data_buffer):
        
        packet = json.loads(data_buffer.decode('utf-8'))

        if packet['cmd'] == 'out':
            # Call os.write manually. In Python2.6, sys.stdout.write doesn't use UTF-8.
            os.write(sys.stdout.fileno(), packet['data'].encode('utf-8'))

        elif packet['cmd'] == 'suspend':
            # Suspend client process to background.
            if hasattr(signal, 'SIGTSTP'):
                os.kill(os.getpid(), signal.SIGTSTP)

        elif packet['cmd'] == 'mode':
            # Set terminal to raw/cooked.
            action = packet['data']

            if action == 'raw':
                cm = raw_mode(sys.stdin.fileno())
                cm.__enter__()
                self._mode_context_managers.append(cm)

            elif action == 'cooked':
                cm = cooked_mode(sys.stdin.fileno())
                cm.__enter__()
                self._mode_context_managers.append(cm)

            elif action == 'restore' and self._mode_context_managers:
                cm = self._mode_context_managers.pop()
                cm.__exit__()
924231
def add_data(self, rawdata):
        """"""

        for data in rawdata:
            try:
                item = data[0]
                if item[0] == 2:
                    # Flush messages but we got nothing to flush
                    continue
                if item[0] != 0:
                    warnings.warn(f"Unknown message type '{item[0]}'", Warning)
                    continue
                item = item[1]
                # convert target to string because error codes are ints
                target = str(item[0])
                try:
                    data = item[1]
                except IndexError:
                    data = dict()
                try:
                    method = getattr(self, self.__head + target)
                    method(data)
                except AttributeError:
                    self._handle_unhandled(target, data)
            except IndexError:
                LOGGER.warning("Wrongly constructed message received: %r", data)

        self.conn.process_queues()
734220
def dataReceived(self, data):
        
        self.stompBuffer.appendData(data)

        while True:
           msg = self.stompBuffer.getOneMessage()
           if msg is None:
               break

           returned = self.react(msg)
           if returned:
               self.transport.write(returned)
975009
def pipe_data_received(self, fd, data):
        """"""
        if fd == 2:  # stderr fd number
            self._on_stderr(data)
        elif self._on_data:
            self._on_data(data)
        else:
            self._queued_data.append(data)
1186806
function update (data) {
    this.bind()
    this.length = data.length
    this.byteLength = this.length * data.BYTES_PER_ELEMENT
    this.gl.bufferData(this.type, data, this.usage)
  }