Create a chunk of the given type with the given data.

@param type
@param data
@returns {Buffer}
968039
function createChunk(type, data) {
	const length = typeof data != 'undefined' ? data.length : 0;
	const chunk = Buffer.alloc(4 + 4 + length + 4);

	chunk.writeUInt32BE(length, 0);
	chunk.fill(type, 4, 8, 'utf8');
	if (typeof data != 'undefined') {
		chunk.fill(data, 8, chunk.length - 4);
	}
	chunk.writeUInt32BE(crc32(chunk.slice(4, -4)), chunk.length - 4);

	return chunk;
}
94699
public static <V> MultipleObjectsBundle makeSimple(SimpleTypeInformation<? super V> type, List<? extends V> data) {
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    bundle.appendColumn(type, data);
    return bundle;
  }
745142
private List<Object> convertType(DataType type, byte[] data)
   {
      List<Object> result = new ArrayList<Object>();
      int index = 0;

      while (index < data.length)
      {
         switch (type)
         {
            case STRING:
            {
               String value = MPPUtility.getUnicodeString(data, index);
               result.add(value);
               index += ((value.length() + 1) * 2);
               break;
            }

            case CURRENCY:
            {
               Double value = Double.valueOf(MPPUtility.getDouble(data, index) / 100);
               result.add(value);
               index += 8;
               break;
            }

            case NUMERIC:
            {
               Double value = Double.valueOf(MPPUtility.getDouble(data, index));
               result.add(value);
               index += 8;
               break;
            }

            case DATE:
            {
               Date value = MPPUtility.getTimestamp(data, index);
               result.add(value);
               index += 4;
               break;

            }

            case DURATION:
            {
               TimeUnit units = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, index + 4), m_properties.getDefaultDurationUnits());
               Duration value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(data, index), units);
               result.add(value);
               index += 6;
               break;
            }

            case BOOLEAN:
            {
               Boolean value = Boolean.valueOf(MPPUtility.getShort(data, index) == 1);
               result.add(value);
               index += 2;
               break;
            }

            default:
            {
               index = data.length;
               break;
            }
         }
      }

      return result;
   }
364464
private void writeTypedBytes(final int type, final byte[] data, final int offset, final int length)
    {
        int totalLength = 1 + length;
        if (length < 14)
        {
            buffer.writeUInt8(type | length);
        }
        else
        {
            // need to specify length explicitly
            buffer.writeUInt8(type | 0xE);
            final int sizeLength = buffer.writeVarUInt(length);
            totalLength += sizeLength;
        }
        updateLength(totalLength);
        buffer.writeBytes(data, offset, length);
    }
1043690
function parseFileChunk(data){
  var chunk = {};
  chunk.chunkIdx = new Float64Array(data.buffer, 8, 1)[0];
  chunk.fileID = String.fromCharCode.apply(null, new Uint16Array(data.buffer, 32, 8));
  chunk.msgIdx = new Float64Array(data.buffer, 16, 1)[0];
  chunk.data = new Uint8Array(data.buffer, 48);
  return chunk;
}
1163298
function(data) {

		return data instanceof Object && (
		(this.domInstance('input', data) && data.type === 'file') ||
		('FileList' in window && data instanceof window.FileList) ||
		('File' in window && data instanceof window.File) ||
		('Blob' in window && data instanceof window.Blob));

	}
175045
function (data, callback) {
    if (typeof txDataQueue != "undefined" || txInProgress) {
      if (txDataQueue === undefined)
        txDataQueue = "";
      txDataQueue += data;
      return callback();
    } else {
      txDataQueue = data;
    }

    function writeChunk() {
      var chunk;
      var CHUNKSIZE = 20;
      if (txDataQueue.length <= CHUNKSIZE) {
        chunk = txDataQueue;
        txDataQueue = undefined;
      } else {
        chunk = txDataQueue.substr(0, CHUNKSIZE);
        txDataQueue = txDataQueue.substr(CHUNKSIZE);
      }
      txInProgress = true;
      console.log("BT> Sending " + JSON.stringify(chunk));
      try {
        winnus.write(chunk);
        setTimeout(function() {
          txInProgress = false;
          if (txDataQueue)
            writeChunk();
        }, 20);
      } catch (e) {
        console.log("BT> ERROR " + e);
        txDataQueue = undefined;
      }
    }
    writeChunk();
    return callback();
  }
737159
function __serializeArrayBuffer(data) {
	let length = data.byteLength;
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, data];
}
995839
function makeConcat(chunkType) {
	switch (chunkType) {
	case BUFFER:
		return (a, b) => Buffer.concat([a, b]);
	default:
		return (a, b) => {
			// console.log('[%d, %d]', a.length, b.length);
			const t = new Uint8Array(a.length + b.length);
			t.set(a);
			t.set(b, a.length);
			// console.log('%d: %s', t.length, new Buffer(t).toString('utf8'));
			return t;
		};
	}
}
1245406
@SuppressWarnings("unchecked")
	public T create(Map<String, Object> data)
	{
		Object[] args = new Object[arguments.length];
		for(int i=0, n=args.length; i<n; i++)
		{
			args[i] = arguments[i].getValue(data);
		}

		try
		{
			return (T) raw.newInstance(args);
		}
		catch(IllegalArgumentException e)
		{
			throw new SerializationException("Unable to create; " + e.getMessage(), e);
		}
		catch(InstantiationException e)
		{
			throw new SerializationException("Unable to create; " + e.getMessage(), e);
		}
		catch(IllegalAccessException e)
		{
			throw new SerializationException("Unable to create; " + e.getMessage(), e);
		}
		catch(InvocationTargetException e)
		{
			throw new SerializationException("Unable to create; " + e.getCause().getMessage(), e.getCause());
		}
	}
885740
function createFrame (type, payload) {
  var err = validateArgs(type, payload);
  if (err) { throw err; }

  var payloadBuffer = Buffer.isBuffer(payload) ? payload : new Buffer(payload);
  var headerBuffer  = createHeader(type, payload.length);

  return Buffer.concat([headerBuffer, payloadBuffer]);
}
652594
public <R> R getData(TypeToken<R> dataType) {
        return GSON.fromJson(data, dataType.getType());
    }
841615
function _type(chunk, test) {
  var b = chunk[0];
  if(b === ERR || b === BST || b === STR || b === INT || b === ARR) {
    if(!test) this._offset++;
    return b;
  }
}
631039
function createEvent (type, data) {
  let event = document.createEvent(specialEvents[type] || 'Event')
  event.initEvent(type, true, true)
  data && (event.data = data)
  return event
}
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));
    }
  }
}
715735
@SuppressWarnings("unchecked")
	private <T> ChunkData<T> createChunkData(String identifier, World world, BlockPos pos)
	{
		Chunk chunk = world.getChunkFromBlockCoords(pos);

		//System.out.println("createChunkData (" + chunk.xPosition + "/" + chunk.zPosition + ") for " + identifier);

		ChunkData<T> chunkData = new ChunkData<>((HandlerInfo<T>) handlerInfos.get(identifier));
		datas.get().put(identifier, chunk, chunkData);
		return chunkData;
	}
332018
function encode(data) {
	const bytes = buffer.Buffer.from(data, 'utf8');
	const pixelData = prependLength(bytes);

	return createPng(pixelData);
}