/*
Converts an object into a Lumberjack data frame

@param {object} data The object to be converted into a Lumberjack frame

@return A Buffer with a Lumberjack frame representing the provided data object
197217
function convertDataToFrame(data, sequence) {
    // Data frame:
    // 1 | D | <sequence> | <nkeys> | <key_length_i> | <key_i> | <val_length_i> | <val_i> | ...

    var dottedNotationData = {};
    objectToFlatDottedNotation(data, '', dottedNotationData);
    logger.debug('Key-value pairs in dotted notation', dottedNotationData);

    var numberOfPairs = Object.keys(dottedNotationData).length;
    var bufferSize = 1 + 1 + 4 + 4 + (4 * numberOfPairs) + (4 * numberOfPairs); // "1" | "D" | <seq> | <nkeys> | 4 * <key_length> | 4 * <val_length>

    for (var k in dottedNotationData) {
        bufferSize += dottedNotationData[k].length + k.length;
    }

    var buffer = new Buffer(bufferSize);
    buffer.write('1D', 0, 2);
    buffer.writeUInt32BE(sequence, 2);
    buffer.writeUInt32BE(numberOfPairs, 6);

    var offset = 10;
    for (k in dottedNotationData) {
        buffer.writeUInt32BE(k.length, offset);
        buffer.write(k, offset + 4, k.length);
        buffer.writeUInt32BE(dottedNotationData[k].length, offset + 4 + k.length);
        buffer.write(dottedNotationData[k], offset + 4 + k.length + 4, dottedNotationData[k].length);
        offset += 4 + k.length + 4 + dottedNotationData[k].length;
    }

    return buffer;
}
45525
function dataToObjects (data) {
  if (!data) return null
  if (data instanceof Array) {
    return data.map(function(doc) { 
      return doc.toObject()
    })
  }
  return data.toObject()
}
161230
function(data) {
    var h, headerArray, headers, i, l, len, o;
    headers = {};
    headerArray = data.getAllResponseHeaders().split('\r');
    for (l = 0, len = headerArray.length; l < len; l++) {
      i = headerArray[l];
      h = i.match(/^([^:]*?):(.*)$/);
      if (!h) {
        h = [];
      }
      h.shift();
      if (h[0] !== void 0 && h[1] !== void 0) {
        headers[h[0].trim()] = h[1].trim();
      }
    }
    o = {};
    o.content = {};
    o.content.data = data.responseText;
    o.headers = headers;
    o.request = {};
    o.request.url = this.invocationUrl;
    o.status = data.status;
    return o;
  }
842859
function makeSimpleBlock(data){
		var flags = 0;
		if (data.keyframe) flags |= 128;
		if (data.invisible) flags |= 8;
		if (data.lacing) flags |= (data.lacing << 1);
		if (data.discardable) flags |= 1;
		if (data.trackNum > 127) {
			throw "TrackNumber > 127 not supported";
		}
		var out = [data.trackNum | 0x80, data.timecode >> 8, data.timecode & 0xff, flags].map(function(e){
			return String.fromCharCode(e)
		}).join('') + data.frame;

		return out;
	}
613789
function(data, padding) {

		var tempResult = [],
			i = 0,
			count = data.length,
			child_padding = padding + "\t",
			result;

		if (count == 0) {

			result = '[]';

		} else if (count == 1) {

			result = '[' + this._serializeValue(data[i], padding) + ']';

		} else {

			for (; i < count; i++) {

				tempResult.push(this._serializeValue(data[i], child_padding));

			}

			result = '[' + "\n\t" + padding + tempResult.join(",\n\t" + padding) + "\n" + padding + ']';

		}

		return result;

	}
1218378
public static Data toHeapData(Data data) {
        if (data == null || data instanceof HeapData) {
            return data;
        }
        return new HeapData(data.toByteArray());
    }
860682
function(data) {
        var response = [];
        var layerNodes = this.getSiblingNodesByTagCriteria(data,
            this.layerIdentifier);
        if (layerNodes) {
            for (var i=0, len=layerNodes.length; i<len; ++i) {
                var node = layerNodes[i];
                var layerName = node.nodeName;
                if (node.prefix) {
                    layerName = layerName.split(':')[1];
                }
                var layerName = layerName.replace(this.layerIdentifier, '');
                var featureNodes = this.getSiblingNodesByTagCriteria(node, 
                    this.featureIdentifier);
                if (featureNodes) {
                    for (var j = 0; j < featureNodes.length; j++) {
                        var featureNode = featureNodes[j];
                        var geomInfo = this.parseGeometry(featureNode);
                        var attributes = this.parseAttributes(featureNode);
                        var feature = new OpenLayers.Feature.Vector(geomInfo.geometry, 
                            attributes, null);
                        feature.bounds = geomInfo.bounds;
                        feature.type = layerName;
                        response.push(feature);
                    }
                }
            }
        }
        return response;
    }
666230
function _normalizeRawData(data) {
  var EmObj = Ember.Object,
      vertices,          // Hash of vertices
      edges,             // Hash of edges
      rootVertices = []; // Vertices without out-edges are considered root vertices

  vertices = data.vertices.reduce(function (obj, vertex) {
    vertex = VertexDataNode.create(vertex);
    if(!vertex.outEdgeIds) {
      rootVertices.push(vertex);
    }
    obj[vertex.vertexName] = vertex;
    return obj;
  }, {});

  edges = !data.edges ? [] : data.edges.reduce(function (obj, edge) {
    obj[edge.edgeId] = EmObj.create(edge);
    return obj;
  }, {});

  if(data.vertexGroups) {
    data.vertexGroups.forEach(function (group) {
      group.groupMembers.forEach(function (vertex) {
        vertices[vertex].vertexGroup = EmObj.create(group);
      });
    });
  }

  return {
    vertices: EmObj.create(vertices),
    edges: EmObj.create(edges),
    rootVertices: rootVertices
  };
}
123567
function(data){
    if(!data || !data.sys) {
      return;
    }
    pinus.data = pinus.data || {};
    var dict = data.sys.dict;
    var protos = data.sys.protos;

    //Init compress dict
    if(dict){
      pinus.data.dict = dict;
      pinus.data.abbrs = {};

      for(var route in dict){
        pinus.data.abbrs[dict[route]] = route;
      }
    }

    //Init protobuf protos
    if(protos){
      pinus.data.protos = {
        server : protos.server || {},
        client : protos.client || {}
      };
      if(!!protobuf){
        protobuf.init({encoderProtos: protos.client, decoderProtos: protos.server});
      }
    }
  }
326664
function fixdata(data) {
		var o = '',
			l = 0,
			w = 10240;
		for (; l < data.byteLength / w; ++l)
			o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
		o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
		return o;
	}
1053937
function(data) {

    var _mode = QRMode.MODE_8BIT_BYTE;
    var _data = data;
    var _parsedData = [];

    var _this = {};


    // Added to support UTF-8 Characters
    for (var i = 0, l = _data.length; i < l; i++) {
	var byteArray = [];
	var code = _data.charCodeAt(i);

	if (code > 0x10000) {
	    byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
	    byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
	    byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
	    byteArray[3] = 0x80 | (code & 0x3F);
	} else if (code > 0x800) {
	    byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
	    byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
	    byteArray[2] = 0x80 | (code & 0x3F);
	} else if (code > 0x80) {
	    byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
	    byteArray[1] = 0x80 | (code & 0x3F);
	} else {
	    byteArray[0] = code;
	}

        // Fix Unicode corruption bug
        _parsedData.push(byteArray);
    }

    _parsedData = Array.prototype.concat.apply([], _parsedData);

    if (_parsedData.length != _data.length) {
	_parsedData.unshift(191);
	_parsedData.unshift(187);
	_parsedData.unshift(239);
    }

    var _bytes = _parsedData;

    _this.getMode = function() {
	return _mode;
    };

    _this.getLength = function(buffer) {
	return _bytes.length;
    };

    _this.write = function(buffer) {
	for (var i = 0; i < _bytes.length; i += 1) {
	    buffer.put(_bytes[i], 8);
	}
    };

    return _this;
}
530598
function stringify(data){
		switch(typeof data){
			case 'string':
				return '"'+ data.replace(reg_rep, function(a){
					return rep[a];
				}) +'"';
			
			case 'object':
				if(data===null){return 'null'}
				var res = [], k, v;
				if(data instanceof Array){
					var l = data.length;
					for(k = 0; k < l; k++){
						v = stringify(data[k]);
						v===undef || res.push(v);
					}
					return '['+ res.join(',') +']';
				}else{
					for(k in data){
						if(data.hasOwnProperty(k) && k){
							v = stringify(data[k]);
							(jskw[k] || reg_d.test(k)) && (k = '"'+k+'"');
							v===undef || res.push(k +':'+ v);
						}
					}
					return '{'+ res.join(',') +'}';
				}

			case 'number':
				return isFinite(data) ? data.toString() : 'null';
			
			case 'undefined':
			case 'unknown':
				return;
			case 'function':
			case 'boolean':
			case 'regexp':
				return data.toString();
		}
	}
70688
function _transform(data, encoding, cb) {
  var res, i = 0, immediate;
  if(this.buffers && (data instanceof Buffer)) {
    this.push(data);
    cb();
  }else{
    // assume you know what you are doing with a raw buffer
    if(Buffer.isBuffer(data) && !this.return_buffers){
      this.push(data);
      cb();
    }else if(this.return_buffers && (data instanceof Buffer)) {
      this.push(_bst(new Buffer(0), data));
      cb();
    }else if(data === undefined
      || data === null
      || Array.isArray(data) && data.length <= this.arrlen
      || (typeof data === 'object' && !Array.isArray(data))
      || typeof data === 'number'
      || (typeof data === 'string' && (data.length < this.strlen))
      || (data instanceof String)) {
      try {
        res = this.value(data);
        //console.dir('' + res);
        this.push(res);
      }catch(e) {
        this.emit('error', e);
        return cb();
      }
      cb();
    // bulk strings broken over ticks
    }else if(typeof data === 'string') {
      // send string length preamble
      res = _len(new Buffer(0), data);
      this.push(res);
      function stringIterator() {
        clearImmediate(immediate);
        var item = data.substr(
          i * this.strlen, (i * this.strlen) + this.strlen);
        if(!item) {
          // send bulk string terminator
          this.push(Constants.ENC.CRLF);
          return cb();
        }
        // send bulk string chunk
        this.push(_bst(new Buffer(0), item, true));
        immediate = setImmediate(stringIterator);
        i++;
      }
      stringIterator = stringIterator.bind(this);
      stringIterator();
    }else if(Array.isArray(data) && data.length > this.arrlen){
      res = _preamble(new Buffer(0), data);
      this.push(res);
      function arrayIterator() {
        clearImmediate(immediate);
        if(i === data.length) return cb();
        var item = data[i];
        this.push(this.value(item));
        immediate = setImmediate(arrayIterator);
        i++;
      }
      arrayIterator = arrayIterator.bind(this);
      arrayIterator();
      //immediate = setImmediate(arrayIterator.bind(this));
    }
  }
}
1291683
public byte[] createDataFrames(List<Object> dataObjects) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();

        for (int i = 0; i < dataObjects.size(); i++) {
            ByteArrayOutputStream dataObjectStream = new ByteArrayOutputStream();
            @SuppressWarnings("unchecked")
            LumberjackEvent<String, String> dataObject = (LumberjackEvent<String, String>) dataObjects.get(i);

            dataObjectStream.write(PROTOCOL_VERSION.getBytes(UTF_8)); //Protocol version
            dataObjectStream.write(DATA_FRAME_TYPE.getBytes(UTF_8)); //Frame type 'D'
            dataObjectStream.write(ByteBuffer.allocate(4).putInt(seqNumber++).array()); //32-bit sequence number
            dataObjectStream.write(ByteBuffer.allocate(4).putInt(dataObject.size()).array()); //32-bit pair count

            for (int j = 0; j < dataObject.size(); j++) {
                Entry<String, String> entry = dataObject.get(j);
                String key = entry.getKey();
                String value = entry.getValue();

                byte[] keyBytes = key.getBytes(UTF_8);
                byte[] valueBytes = value.getBytes(UTF_8);
                dataObjectStream.write(ByteBuffer.allocate(4).putInt(keyBytes.length).array()); //32-bit key length
                dataObjectStream.write(keyBytes); //Key
                dataObjectStream.write(ByteBuffer.allocate(4).putInt(valueBytes.length).array()); //32-bit value length
                dataObjectStream.write(valueBytes);//Value
            }

            output.write(dataObjectStream.toByteArray());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "created data frame for " + dataObjects.size() + " events - last sequence number used = " + (seqNumber - 1));

        return output.toByteArray();
    }
530180
private DataBuffer withDataBufferFactory(ByteBufHttpData data) {
        final byte[] dataArray = ByteBufUtil.getBytes(data.content());
        data.release();
        return delegate.wrap(dataArray);
    }
894355
function(data) {
      var extras = {};

      if (data instanceof File) {
        extras = this.meta(data);
        data = data.toDataURL();
      }
      var parts = data.split(","), headers = parts[0].split(":"), body;

      if (parts.length !== 2 || headers.length !== 2 || headers[0] !== "data") {
        throw new Error("Invalid data URI.");
      }
      headers = headers[1].split(";");
      body = (headers[1] === "base64") ? atob(parts[1]) : decodeURI(parts[1]);
      var length = body.length, buffer = new ArrayBuffer(length), bytes = new Uint8Array(buffer);

      for (var i = 0; i < length; i++) {
        bytes[i] = body.charCodeAt(i);
      }
      return angular.extend(new Blob([bytes], { type: headers[0] }), extras);
    }
42299
function clone (data) {
  if (Array.isArray(data)) {
    return data.map(clone)
  } else if (data && typeof data === 'object') {
    let obj = Object.assign({}, data)
    for (let key in obj) {
      if (!obj.hasOwnProperty(key)) continue
      if (typeof obj[key] === 'object') {
        obj[key] = clone(obj[key])
      }
    }
    return obj
  } else {
    return data
  }
}