How to use the @xviz/builder/utils/load-uri.js.parseDataUri function in @xviz/builder

To help you get started, we’ve selected a few @xviz/builder 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 / builder / loader-utils / load-uri.spec.js View on Github external
test('parseDataUri', t => {
  let obj;
  let buf;

  obj = parseDataUri('data:text/html;base64,PGh0bWw+');
  t.equals(obj.mimeType, 'text/html', 'should record down correct MIME type');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with non-padded base64 data URIs');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE=');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');

  obj = parseDataUri('data:,important content!');
  t.equals(obj.mimeType, 'text/plain;charset=US-ASCII', 'should set default MIME type');
github uber / xviz / test / modules / builder / loader-utils / load-uri.spec.js View on Github external
test('parseDataUri', t => {
  let obj;
  let buf;

  obj = parseDataUri('data:text/html;base64,PGh0bWw+');
  t.equals(obj.mimeType, 'text/html', 'should record down correct MIME type');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with non-padded base64 data URIs');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE=');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');

  obj = parseDataUri('data:,important content!');
  t.equals(obj.mimeType, 'text/plain;charset=US-ASCII', 'should set default MIME type');

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with default MIME type');
github uber / xviz / test / modules / builder / loader-utils / load-uri.spec.js View on Github external
test('parseDataUri', t => {
  let obj;
  let buf;

  obj = parseDataUri('data:text/html;base64,PGh0bWw+');
  t.equals(obj.mimeType, 'text/html', 'should record down correct MIME type');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with non-padded base64 data URIs');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE=');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');
github uber / xviz / test / modules / builder / loader-utils / load-uri.spec.js View on Github external
obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with non-padded base64 data URIs');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE=');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');

  obj = parseDataUri('data:,important content!');
  t.equals(obj.mimeType, 'text/plain;charset=US-ASCII', 'should set default MIME type');

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with default MIME type');

  obj = parseDataUri('data:;charset=utf-8,important content!');
  t.equals(
    obj.mimeType,
    'text/plain;charset=utf-8',
    'should allow implicit text/plain with charset'
  );

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should allow implicit text/plain with charset');
github uber / xviz / test / modules / builder / loader-utils / load-uri.spec.js View on Github external
let buf;

  obj = parseDataUri('data:text/html;base64,PGh0bWw+');
  t.equals(obj.mimeType, 'text/html', 'should record down correct MIME type');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with non-padded base64 data URIs');

  obj = parseDataUri('data:text/plain;base64,SSBsb3ZlIHlvdSE=');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');

  obj = parseDataUri('data:,important content!');
  t.equals(obj.mimeType, 'text/plain;charset=US-ASCII', 'should set default MIME type');

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with default MIME type');

  obj = parseDataUri('data:;charset=utf-8,important content!');
  t.equals(
    obj.mimeType,
    'text/plain;charset=utf-8',
    'should allow implicit text/plain with charset'
github uber / xviz / test / modules / builder / loader-utils / load-uri.spec.js View on Github external
t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'I love you!', 'should work with padded base64 data URIs');

  obj = parseDataUri('data:text/plain,important content!');
  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with plain data URIs');

  obj = parseDataUri('data:,important content!');
  t.equals(obj.mimeType, 'text/plain;charset=US-ASCII', 'should set default MIME type');

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should work with default MIME type');

  obj = parseDataUri('data:;charset=utf-8,important content!');
  t.equals(
    obj.mimeType,
    'text/plain;charset=utf-8',
    'should allow implicit text/plain with charset'
  );

  buf = obj.buffer;
  t.ok(Buffer.isBuffer(buf));
  t.equals(buf.toString(), 'important content!', 'should allow implicit text/plain with charset');

  t.end();
});