microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
indexed-sourcemap-null-section-issue

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/networkInspector/requestBodyFormatters/utils.ts

40lines · modeblame

4bb0956eRedMickey5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
09f6024fHeniker4 years ago4/* eslint-disable */
5/* eslint-enable prettier/prettier*/
6
4bb0956eRedMickey5 years ago7import { TextDecoder } from "util";
8import { Base64 } from "js-base64";
9
10/**
11* @preserve
12* Start region: the code is borrowed from https://github.com/facebook/flipper/blob/v0.79.1/desktop/plugins/network/chunks.tsx#L12-L28
13*
14* Copyright (c) Facebook, Inc. and its affiliates.
15*
16* This source code is licensed under the MIT license found in the
17* LICENSE file in the root directory of this source tree.
18*
19* @format
20*/
21
22export function combineBase64Chunks(chunks: string[]): string {
23const byteArray = chunks.map(
24b64Chunk => Uint8Array.from(Base64.atob(b64Chunk), c => c.charCodeAt(0)).buffer,
25);
26const size = byteArray.map(b => b.byteLength).reduce((prev, curr) => prev + curr, 0);
27const buffer = new Uint8Array(size);
28let offset = 0;
29for (let i = 0; i < byteArray.length; i++) {
30buffer.set(new Uint8Array(byteArray[i]), offset);
31offset += byteArray[i].byteLength;
32}
33const data = new TextDecoder("utf-8").decode(buffer);
34return data;
35}
36
37/**
38* @preserve
39* End region: https://github.com/facebook/flipper/blob/v0.79.1/desktop/plugins/network/chunks.tsx#L12-L28
40*/