How to use the capnp-ts/lib/util.pad function in capnp-ts

To help you get started, we’ve selected a few capnp-ts 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 jdiaz5513 / capnp-ts / packages / capnpc-ts / src / util.ts View on Github external
export function d2h(d: string): string {
  let h = decToHex(d).substr(2);
  let neg = false;

  if (h[0] === "-") {
    h = h.substr(1);

    neg = true;
  }

  return neg ? `-${pad(h, 16)}` : pad(h, 16);
}
github jdiaz5513 / capnp-ts / packages / capnpc-ts / src / ast-creators.ts View on Github external
case s.Value.FLOAT64:
      return ts.createNumericLiteral(value.getFloat64().toString());

    case s.Value.INT16:
      return ts.createNumericLiteral(value.getInt16().toString());

    case s.Value.INT32:
      return ts.createNumericLiteral(value.getInt32().toString());

    case s.Value.INT64:
      const int64 = value.getInt64();
      const int64Bytes: string[] = [];

      for (let i = 0; i < 8; i++) {
        int64Bytes.push(`0x${pad(int64.buffer[i].toString(16), 2)}`);
      }

      const int64ByteArray = ts.createArrayLiteral(
        int64Bytes.map(ts.createNumericLiteral),
        false
      );
      const int64ArrayBuffer = ts.createNew(
        ts.createIdentifier("Uint8Array"),
        __,
        [int64ByteArray]
      );
      return ts.createNew(ts.createIdentifier("capnp.Int64"), __, [
        int64ArrayBuffer
      ]);

    case s.Value.INT8: