How to use abab - 10 common examples

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 withspectrum / spectrum / shared / graphql / queries / directMessageThread / getDirectMessageThreadMessageConnection.js View on Github external
} else if (existingMessage) {
            return prev;
          }

          // Add the new message to the data
          return Object.assign({}, prev, {
            ...prev,
            directMessageThread: {
              ...prev.directMessageThread,
              messageConnection: {
                ...prev.directMessageThread.messageConnection,
                edges: [
                  ...prev.directMessageThread.messageConnection.edges,
                  {
                    node: newMessage,
                    cursor: btoa(newMessage.id),
                    __typename: 'DirectMessageEdge',
                  },
                ],
              },
            },
          });
        },
      });
github elastic / kibana / x-pack / dev-tools / api_debug / request_from_api.js View on Github external
function getRequestParams(argv) {
  // use `--host=https://somedomain.com:5601` or else http://localhost:5601 is defaulted
  const host = argv.host || 'http://localhost:5601';
  // use `--auth=myuser:mypassword` or else elastic:changeme is defaulted
  // passing `--auth` with no value effectively sends no auth
  const auth = argv.auth || 'elastic:changeme';
  const authStr = abab.btoa(auth);
  // auto-add a leading slash to basePath
  const basePath = argv.basePath ? '/' + argv.basePath : '';

  return {
    host,
    auth: `Basic ${authStr}`,
    basePath,
  };
}
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 GreenImp / rpg-dice-roller / spec / helpers / custom-matchers.helper.js View on Github external
isBase64Encoded(obj){
      try{
        return obj && (btoa(atob(obj)) === obj);
      }catch(e){
        return false;
      }
    }
  };
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