How to use the abab.atob function in abab

To help you get started, we’ve selected a few abab 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 webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
};
        const fetchContent = this.fetchContent.bind(this);

        const defaultBody = { content, rawContent, rawResponse };

        if (cdpResponse.response.status !== 200) {
            // TODO: is this right? no-friendly-error-pages won't have a problem?
            return defaultBody;
        }

        try {
            await this.waitForContentLoaded(cdpResponse.requestId);
            const { body, base64Encoded } = await this._client.Network.getResponseBody({ requestId: cdpResponse.requestId });
            const encoding = base64Encoded ? 'base64' : 'utf-8';

            content = base64Encoded ? atob(body) : body; // There are some JS responses that are base64Encoded for some weird reason
            rawContent = Buffer.from(body, encoding);

            const returnValue = {
                content,
                rawContent,
                rawResponse(): Promise {
                    const self = (this as { _rawResponse: Promise });

                    if (self) {
                        const cached = self._rawResponse;

                        if (cached) {
                            return Promise.resolve(cached);
                        }
                    }
github webhintio / hint / packages / utils-debugging-protocol-common / src / request-response.ts View on Github external
const normalizedHeaders = normalizeHeaders(headers);
            const that = this;

            let rawContent = Buffer.alloc(0);
            let rBody = {
                content: '',
                rawContent,
                rawResponse: () => {
                    return Promise.resolve(Buffer.alloc(0));
                }
            };

            if (this._responseBody) {
                const { body, base64Encoded } = this._responseBody;
                const encoding = base64Encoded ? 'base64' : 'utf-8';
                const content = base64Encoded ? atob(body) : body; // There are some JS responses that are base64 encoded for some reason

                rawContent = Buffer.from(body, encoding);

                rBody = {
                    content,
                    rawContent,
                    rawResponse: () => {
                        return that.getRawResponse();
                    }
                };
            }

            this._response = {
                body: rBody,
                charset: null!,
                headers: normalizedHeaders!,
github filestack / filestack-js / src / adapters / file_utils.browser.ts View on Github external
const b64toBlob = (b64Data: string, sliceSize = 512) => {
  let byteString;
  let contentType = '';
  if (b64Data.split(',')[0].indexOf('base64') >= 0) {
    byteString = b64Data.split(',')[1];
  }
  if (byteString !== undefined) {
    contentType = b64Data.split(',')[0].split(':')[1].split(';')[0];
    b64Data = decodeURI(byteString);
  }
  const byteCharacters = atob(b64Data);
  const byteArrays: any[] = [];
  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
    const slice = byteCharacters.slice(offset, offset + sliceSize);
    const byteNumbers = new Array(slice.length);
    for (let i = 0; i < slice.length; i += 1) {
      byteNumbers[i] = slice.charCodeAt(i);
    }
    const byteArray = new Uint8Array(byteNumbers);
    byteArrays.push(byteArray);
  }
  const blob = new Blob(byteArrays, { type: contentType });
  return blob;
};
github sx1989827 / DOClever / node_modules / data-urls / lib / utils.js View on Github external
exports.forgivingBase64Decode = data => {
  const asString = atob(data);
  if (asString === null) {
    return null;
  }
  return Buffer.from(asString, "binary");
};
github jsdom / data-urls / lib / utils.js View on Github external
exports.forgivingBase64Decode = data => {
  const asString = atob(data);
  if (asString === null) {
    return null;
  }
  return Buffer.from(asString, "binary");
};
github jsdom / jsdom / lib / jsdom / browser / Window.js View on Github external
this.atob = function (str) {
    const result = atob(str);
    if (result === null) {
      throw new DOMException("The string to be decoded contains invalid characters.", "InvalidCharacterError");
    }
    return result;
  };
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / browser / Window.js View on Github external
this.atob = function (str) {
    const result = atob(str);
    if (result === null) {
      throw new DOMException("The string to be decoded contains invalid characters.", "InvalidCharacterError");
    }
    return result;
  };

abab

WHATWG spec-compliant implementations of window.atob and window.btoa.

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Popular abab functions