How to use data-uri-to-buffer - 4 common examples

To help you get started, we’ve selected a few data-uri-to-buffer 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 tec27 / seatcamp / lib / meatspace-proxy.js View on Github external
onMessage(chat) {
    if (this.awaiting.dec(chat.fingerprint)) {
      // This is a message we proxied, drop it!
      return
    } else {
      // This is a message we didn't send, do the final necessary conversions and send it on!
      const converted = {
        fingerprint: chat.fingerprint,
        message: chat.message,
        media: {},
        created: chat.created,
        key: chat.key,
      }

      // decode the webm
      const decoded = uriToBuffer(chat.media)
      this.lastMessageTime = converted.created
      frameConverter(decoded, this.ffmpegRunner, (err, filmstrip) => {
        if (err) {
          console.error('Error converting meatspace chat to filmstrip: ' + err)
          return
        }

        converted.media['image/jpeg'] = filmstrip
        this.emit('chat', converted)
      })
    }
  }
}
github getsentry / sourcemaps.io / server / src / lib / validateSourceMap.ts View on Github external
function requestSourceMap(
  sourceMapUrl: string,
  options: request.CoreOptions,
  callback: (error: any, response: Partial<request.Response>, body: any) => void
) {
  if (sourceMapUrl.startsWith('data:')) {
    const body = dataUriToBuffer(sourceMapUrl);

    // mock response object; pretend we made a http request
    callback(
      null,
      {
        statusCode: 200
      },
      body.toString()
    );
  } else {
    request(sourceMapUrl, options, callback as request.RequestCallback);
  }
}
github firefox-devtools / vscode-firefox-debug / src / adapter / util / net.ts View on Github external
export async function getUri(uri: string): Promise<string> {

	if (uri.startsWith('data:')) {
		return dataUriToBuffer(uri).toString();
	}

	if (uri.startsWith('file:')) {
		return await fs.readFile(fileUriToPath(uri), 'utf8');
	}

	if (!uri.startsWith('http:') && !uri.startsWith('https:')) {
		throw new Error(`Fetching ${uri} not supported`);
	}

	return await new Promise<string>((resolve, reject) => {
		const parsedUrl = url.parse(uri);
		const get = (parsedUrl.protocol === 'https:') ? https.get : http.get;
		const options = Object.assign({ rejectUnauthorized: false }, parsedUrl) as https.RequestOptions;

		get(options, response => {
github SideProjectGuys / invite-manager-bot / src / example / qr.ts View on Github external
return new Promise(res => {
		return new Jimp(dataUriToBuffer(dataUri), (err, img) => {
			if (err) {
				throw err;
			}
			res(img);
		});
	});
}

data-uri-to-buffer

Generate a Buffer instance from a Data URI string

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis

Popular data-uri-to-buffer functions