Parse data from the current buffer offset using a function.
777294
def read_func(self, func, num_bytes=None):
        """"""
        # only advance if func succeeds
        res = func(self.get_next(num_bytes))
        self.skip(num_bytes)
        return res
999657
function parse(string) {

    var buffer = newBufferFromSize(16);
    var j = 0;
    for (var i = 0; i < 16; i++) {
        buffer[i] = hex2byte[string[j++] + string[j++]];
        if (i === 3 || i === 5 || i === 7 || i === 9) {
            j += 1;
        }
    }

    return buffer;
}
330337
function readVarInt (buffer, offset) {
  const result = varuint.decode(buffer, offset);

  return {
    number: result,
    size: varuint.decode.bytes
  };
}
178125
def _read(self, f):
        """"""
        
        try:
            self.header = ord(f.read(1))
        except TypeError:
            log.debug("buffer underflow at offset {0}".format(f.tell()))
            raise LengthError("insufficient data to parse")
        
        mbf = bool(self.header & 0x80)
        mef = bool(self.header & 0x40)
        cff = bool(self.header & 0x20)
        srf = bool(self.header & 0x10)
        ilf = bool(self.header & 0x08)
        tnf = self.header & 0x07

        try:
            type_length = ord(f.read(1))
            if srf: # short record
                data_length = ord(f.read(1))
            else: # 32-bit length
                data_length = struct.unpack('>L', f.read(4))[0]
            if ilf: # id length present
                name_length = ord(f.read(1))
            else:
                name_length = 0
        except (TypeError, struct.error):
            log.debug("buffer underflow at offset {0}".format(f.tell()))
            raise LengthError("insufficient data to parse")

        try:
            record_type = f.read(type_length)
            assert len(record_type) == type_length
            record_name = f.read(name_length)
            assert len(record_name) == name_length
            record_data = f.read(data_length)
            assert len(record_data) == data_length
        except AssertionError:
            log.debug("buffer underflow at offset {0}".format(f.tell()))
            raise LengthError("insufficient data to parse")

        if tnf in (0, 5, 6) and len(record_type) > 0:
            s = "ndef type name format {0} doesn't allow a type string"
            raise FormatError( s.format(tnf) )
        if tnf in (1, 2, 3, 4) and len(record_type) == 0:
            s = "ndef type name format {0} requires a type string"
            raise FormatError( s.format(tnf) )
        if tnf == 0 and len(record_data) > 0:
            s = "ndef type name format {0} doesn't allow a payload"
            raise FormatError( s.format(tnf) )
            
        self._message_begin, self._message_end = mbf, mef
        self._type = bytearray(type_name_prefix[tnf] + record_type)
        self._name = bytearray(record_name)
        self._data = bytearray(record_data)
        log.debug("parsed {0}".format(repr(self)))
574933
def read_until(self, delimiter):
        """"""
        if delimiter in self._buffer:
            data, delimiter, self._buffer = self._buffer.partition(delimiter)
            return data
        else:
            self._buffer += self.__read__(self._max_bytes)
            return self.read_until(delimiter)
598538
def _parse_value(cls, stream_rdr, offset, value_count, value_offset):
        
        return stream_rdr.read_str(value_count-1, value_offset)
1150155
function parse(s, buf, offset) {
  const i = (buf && offset) || 0;
  var ii = 0;

  if (buf) buf.fill(0, i, i + 16);
  buf = buf || new Buffer(16);
  s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
    if (ii < 16) { // Don't overflow!
      buf[i + ii++] = _hexToByte[oct];
    }
  });

  var buf2 = new Buffer(buf.slice(i, i + 16));
  buf[i + 0] = buf2[3];
  buf[i + 1] = buf2[2];
  buf[i + 2] = buf2[1];
  buf[i + 3] = buf2[0];
  buf[i + 4] = buf2[5];
  buf[i + 5] = buf2[4];
  buf[i + 6] = buf2[7];
  buf[i + 7] = buf2[6];

  return buf;
}
738231
function parse(str, callback) {
	process.nextTick(function () {
		var output = parseSync(str);
		callback(output);
	});
}
316251
def parse_result(self, data):
        
        # typedef struct {
        #   uint8_t numBytes;                   // Number of bytes in buffer now
        # } YSM_BUFFER_LOAD_RESP;
        count = ord(data[0])
        if self.offset == 0:
            # if offset was 0, the buffer was reset and
            # we can verify the length returned
            if count != self.data_len:
                raise pyhsm.exception.YHSM_Error("Incorrect number of bytes in buffer (got %i, expected %i)" \
                                               % (self.data_len, count))
        return count
450707
function parseCFFIndex(reader, offset, conversionFn) {
            if (offset) {
                reader.seek(offset);
            }
            var start = reader.offset;
            var offsets = [];
            var objects = [];
            var count = reader.readUint16();
            var i;
            var l;
            if (count !== 0) {
                var offsetSize = reader.readUint8();
                for (i = 0, l = count + 1; i < l; i++) {
                    offsets.push(getOffset(reader, offsetSize));
                }

                for (i = 0, l = count; i < l; i++) {
                    var value = reader.readBytes(offsets[i + 1] - offsets[i]);
                    if (conversionFn) {
                        value = conversionFn(value);
                    }
                    objects.push(value);
                }
            }

            return {
                objects: objects,
                startOffset: start,
                endOffset: reader.offset
            };
        }
797725
function parse(str, options, callback) {
	if (typeof options === 'function') {
		callback = options
		options = {}
	}
	process.nextTick(() => {
		const output = parseSync(str, options)
		callback(output)
	})
}
557479
def _parse(self):
        """"""
        while self._cur_token['type'] in (TT.ws, TT.lbreak):
            self._skip_whitespace()
            self._skip_newlines()

        self._data = self._parse_value()

        return self._data
1170873
def _read_bytes(fp, buf):
    

    # Do the first read without resizing the input buffer
    offset = 0
    remaining = len(buf)
    while remaining > 0:
        l = fp.readinto((ctypes.c_char * remaining).from_buffer(buf, offset))
        if l is None or l == 0:
            return offset
        offset += l
        remaining -= l
    return offset
24047
def read_in_chunks(file_obj, chunk_size):
    """"""
    offset = 0
    while True:
        data = file_obj.read(chunk_size)
        if not data:
            break
        yield data, offset
        offset += len(data)
832784
function (block, buffer, offset) {
    var start = offset % block
    var length = buffer.readUInt16LE(start)
    if(length === block - 1)
      return null
    else {
      var _length = buffer.readUInt16LE(start+2+length)
      if(_length != length)
        throw new Error('expected matching length at end, expected:'+length+', was:'+_length)
      result.offset = offset
      result.start = start+2
      result.length = length
      return result
    }
  }
1248552
def parse(self, buffer, inlineparent = None):
        '''
        
        '''
        size = 0
        v = []
        for i in range(0, self.size):  # @UnusedVariable
            r = self.innerparser.parse(buffer[size:], None)
            if r is None:
                return None
            v.append(r[0])
            size += r[1]
        return (v, size)
637027
def buffered_read(fh, lock, offsets, bytecounts, buffersize=None):
    """"""
    if buffersize is None:
        buffersize = 2**26
    length = len(offsets)
    i = 0
    while i < length:
        data = []
        with lock:
            size = 0
            while size < buffersize and i < length:
                fh.seek(offsets[i])
                bytecount = bytecounts[i]
                data.append(fh.read(bytecount))
                # buffer = bytearray(bytecount)
                # n = fh.readinto(buffer)
                # data.append(buffer[:n])
                size += bytecount
                i += 1
        for segment in data:
            yield segment