How to use the @xviz/io.XVIZ_FORMAT.JSON_BUFFER function in @xviz/io

To help you get started, we’ve selected a few @xviz/io 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 uber / xviz / test / modules / io / common / xviz-data.spec.js View on Github external
format: XVIZ_FORMAT.JSON_STRING
  },
  {
    data: TestXVIZSnapshotBuffer,
    description: 'XVIZ String Buffer',
    format: XVIZ_FORMAT.JSON_BUFFER
  },
  {
    data: TestXVIZSnapshotGLB,
    description: 'XVIZ Binary Buffer',
    format: XVIZ_FORMAT.BINARY_GLB
  },
  {
    data: Buffer.from(TestXVIZSnapshotBuffer),
    description: 'XVIZ String NodeBuffer',
    format: XVIZ_FORMAT.JSON_BUFFER,
    nodeOnly: true
  },
  {
    data: Buffer.from(TestXVIZSnapshotGLB),
    description: 'XVIZ Binary NodeBuffer',
    format: 'BINARY_GLB',
    nodeOnly: true
  }
];

tape('XVIZData#constructor', t => {
  const isBrowser = typeof window !== 'undefined';

  for (const test of TestCases) {
    if (test.nodeOnly === true && isBrowser) {
      continue; // eslint-disable-line no-continue
github uber / xviz / test / modules / io / writers / xviz-format-writer.spec.js View on Github external
tape('XVIZFormatWriter#full matrix', t => {
  const dataSources = [
    TestXVIZSnapshot,
    TestXVIZSnapshotString,
    TestXVIZSnapshotBuffer,
    TestXVIZSnapshotGLB
  ];
  for (const source of dataSources) {
    const xvizObj = new XVIZData(source);

    for (const format of [
      XVIZ_FORMAT.BINARY_GLB,
      XVIZ_FORMAT.JSON_BUFFER,
      XVIZ_FORMAT.JSON_STRING
    ]) {
      const sink = new MemorySourceSink();

      t.comment(`-- TestCase ${xvizObj.format} to ${format}`);

      // Convert the data to the requested format
      // data is state_update and this will default to a message sequence of 0
      const formatWriter = new XVIZFormatWriter(sink, {format});
      formatWriter.writeMessage(0, xvizObj);

      // We don't really care about the key as each writer will have
      // different identifier, (eg: 1-frame.json vs 1.frame.glb)
      for (const [key, val] of sink.entries()) {
        // Cover Arrays, Strings, ArrayBuffers
        t.ok(val.byteLength || val.length, `${key} has formatted data`);
github uber / xviz / test / modules / io / common / xviz-data.spec.js View on Github external
format: XVIZ_FORMAT.OBJECT
  },
  {
    data: TestXVIZSnapshotString,
    description: 'XVIZ String',
    format: XVIZ_FORMAT.JSON_STRING
  },
  {
    data: `   ${TestXVIZSnapshotString}   `,
    description: 'XVIZ String with whitespace head and tail',
    format: XVIZ_FORMAT.JSON_STRING
  },
  {
    data: TestXVIZSnapshotBuffer,
    description: 'XVIZ String Buffer',
    format: XVIZ_FORMAT.JSON_BUFFER
  },
  {
    data: TestXVIZSnapshotGLB,
    description: 'XVIZ Binary Buffer',
    format: XVIZ_FORMAT.BINARY_GLB
  },
  {
    data: Buffer.from(TestXVIZSnapshotBuffer),
    description: 'XVIZ String NodeBuffer',
    format: XVIZ_FORMAT.JSON_BUFFER,
    nodeOnly: true
  },
  {
    data: Buffer.from(TestXVIZSnapshotGLB),
    description: 'XVIZ Binary NodeBuffer',
    format: 'BINARY_GLB',