How to use the flatbuffers.ByteBuffer function in flatbuffers

To help you get started, we’ve selected a few flatbuffers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / flatbuffers_v1.5.x / flow_v0.104.x- / test_flatbuffers_v1.5.x.js View on Github external
la.toFloat64();

la.equals(lb);
// $ExpectError
la.equals(10);

/**
 * ByteBuffer
 */
const arr = new Uint8Array(10);
let bb = new fb.ByteBuffer(arr);
// $ExpectError arg is required
new fb.ByteBuffer();
// $ExpectError arg must be number
new fb.ByteBuffer("s");

fb.ByteBuffer.allocate(10);
// $ExpectError
fb.ByteBuffer.allocate();
// $ExpectError
fb.ByteBuffer.allocate("s");

bb.bytes();
bb.position();

bb.setPosition(1);
// $ExpectError
bb.setPosition();
// $ExpectError
bb.setPosition("s");
github flow-typed / flow-typed / definitions / npm / flatbuffers_v1.5.x / flow_v0.104.x- / test_flatbuffers_v1.5.x.js View on Github external
// $ExpectError
new fb.Long.create();
// $ExpectError
new fb.Long.create("s", "t");

la.toFloat64();

la.equals(lb);
// $ExpectError
la.equals(10);

/**
 * ByteBuffer
 */
const arr = new Uint8Array(10);
let bb = new fb.ByteBuffer(arr);
// $ExpectError arg is required
new fb.ByteBuffer();
// $ExpectError arg must be number
new fb.ByteBuffer("s");

fb.ByteBuffer.allocate(10);
// $ExpectError
fb.ByteBuffer.allocate();
// $ExpectError
fb.ByteBuffer.allocate("s");

bb.bytes();
bb.position();

bb.setPosition(1);
// $ExpectError
github jkcfg / jk / std / std_param.js View on Github external
__std.ParamArgs.addPath(builder, pathOffset);
  __std.ParamArgs.addType(builder, type);
  if (isObject) {
    __std.ParamArgs.addDefaultValue(builder, defaultValueOffset);
  }
  const argsOffset = __std.ParamArgs.endParamArgs(builder);

  __std.Message.startMessage(builder);
  __std.Message.addArgsType(builder, __std.Args.ParamArgs);
  __std.Message.addArgs(builder, argsOffset);
  const messageOffset = __std.Message.endMessage(builder);
  builder.finish(messageOffset);

  const bytes = V8Worker2.send(builder.asArrayBuffer());

  const buf = new flatbuffers.ByteBuffer(new Uint8Array(bytes));
  const resp = __std.ParamResponse.getRootAsParamResponse(buf);

  switch (resp.retvalType()) {
  case __std.ParamRetval.ParamValue: {
    // The runtime has returned the parameter value (or null).
    const ret = new __std.ParamValue();
    resp.retval(ret);

    const v = JSON.parse(ret.json());
    if (v == null) {
      return defaultValue;
    }
    return v;
  }
  case __std.ParamRetval.Error: {
    // The runtime has returned an error.