当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript msg_generated.Base类代码示例

本文整理汇总了TypeScript中gen/msg_generated.Base的典型用法代码示例。如果您正苦于以下问题:TypeScript Base类的具体用法?TypeScript Base怎么用?TypeScript Base使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Base类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: maybeError

export function maybeError(base: Base): null | DenoError<ErrorKind> {
  const kind = base.errorKind();
  if (kind === ErrorKind.NoError) {
    return null;
  } else {
    return new DenoError(kind, base.error()!);
  }
}
开发者ID:F001,项目名称:deno,代码行数:8,代码来源:errors.ts

示例2: sendSync

export function sendSync(
  builder: flatbuffers.Builder,
  innerType: msg.Any,
  inner: flatbuffers.Offset,
  data?: ArrayBufferView
): null | msg.Base {
  const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true);
  util.assert(cmdId >= 0);
  if (resBuf == null) {
    return null;
  } else {
    const u8 = new Uint8Array(resBuf!);
    const bb = new flatbuffers.ByteBuffer(u8);
    const baseRes = msg.Base.getRootAsBase(bb);
    errors.maybeThrowError(baseRes);
    return baseRes;
  }
}
开发者ID:F001,项目名称:deno,代码行数:18,代码来源:dispatch.ts

示例3: handleAsyncMsgFromRust

export function handleAsyncMsgFromRust(ui8: Uint8Array) {
  // If a the buffer is empty, recv() on the native side timed out and we
  // did not receive a message.
  if (ui8 && ui8.length) {
    const bb = new flatbuffers.ByteBuffer(ui8);
    const base = msg.Base.getRootAsBase(bb);
    const cmdId = base.cmdId();
    const promise = promiseTable.get(cmdId);
    util.assert(promise != null, `Expecting promise in table. ${cmdId}`);
    promiseTable.delete(cmdId);
    const err = errors.maybeError(base);
    if (err != null) {
      promise!.reject(err);
    } else {
      promise!.resolve(base);
    }
  }
  // Fire timers that have become runnable.
  fireTimers();
}
开发者ID:F001,项目名称:deno,代码行数:20,代码来源:dispatch.ts

示例4: sendInternal

function sendInternal(
  builder: flatbuffers.Builder,
  innerType: msg.Any,
  inner: flatbuffers.Offset,
  data: undefined | ArrayBufferView,
  sync = true
): [number, null | Uint8Array] {
  const cmdId = nextCmdId++;
  msg.Base.startBase(builder);
  msg.Base.addInner(builder, inner);
  msg.Base.addInnerType(builder, innerType);
  msg.Base.addSync(builder, sync);
  msg.Base.addCmdId(builder, cmdId);
  builder.finish(msg.Base.endBase(builder));
  const res = libdeno.send(builder.asUint8Array(), data);
  builder.inUse = false;
  return [cmdId, res];
}
开发者ID:F001,项目名称:deno,代码行数:18,代码来源:dispatch.ts


注:本文中的gen/msg_generated.Base类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。