MCPcopy
hub / github.com/socketio/socket.io / decode$1

Function decode$1

packages/socket.io/client-dist/socket.io.js:266–293  ·  view source on GitHub ↗
(base64)

Source from the content-addressed store, hash-verified

264 lookup$1[chars.charCodeAt(i)] = i;
265 }
266 var decode$1 = function decode(base64) {
267 var bufferLength = base64.length * 0.75,
268 len = base64.length,
269 i,
270 p = 0,
271 encoded1,
272 encoded2,
273 encoded3,
274 encoded4;
275 if (base64[base64.length - 1] === '=') {
276 bufferLength--;
277 if (base64[base64.length - 2] === '=') {
278 bufferLength--;
279 }
280 }
281 var arraybuffer = new ArrayBuffer(bufferLength),
282 bytes = new Uint8Array(arraybuffer);
283 for (i = 0; i < len; i += 4) {
284 encoded1 = lookup$1[base64.charCodeAt(i)];
285 encoded2 = lookup$1[base64.charCodeAt(i + 1)];
286 encoded3 = lookup$1[base64.charCodeAt(i + 2)];
287 encoded4 = lookup$1[base64.charCodeAt(i + 3)];
288 bytes[p++] = encoded1 << 2 | encoded2 >> 4;
289 bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
290 bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
291 }
292 return arraybuffer;
293 };
294
295 var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function";
296 var decodePacket = function decodePacket(encodedPacket, binaryType) {

Callers 1

decodeBase64PacketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected