MCPcopy Index your code
hub / github.com/plotly/plotly.js / base64clean

Function base64clean

stackgl_modules/index.js:1406–1418  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1404
1405var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1406function base64clean(str) {
1407 // Node takes equal signs as end of the Base64 encoding
1408 str = str.split('=')[0];
1409 // Node strips out invalid characters like \n and \t from the string, base64-js does not
1410 str = str.trim().replace(INVALID_BASE64_RE, '');
1411 // Node converts strings with length < 2 to ''
1412 if (str.length < 2) return '';
1413 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1414 while (str.length % 4 !== 0) {
1415 str = str + '=';
1416 }
1417 return str;
1418}
1419function utf8ToBytes(string, units) {
1420 units = units || Infinity;
1421 var codePoint;

Callers 1

base64ToBytesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…