MCPcopy Create free account
hub / github.com/microsoft/SandDance / getLens

Function getLens

docs/app/js/sanddance-app.js:114099–114111  ·  view source on GitHub ↗
(b64)

Source from the content-addressed store, hash-verified

114097revLookup["-".charCodeAt(0)] = 62;
114098revLookup["_".charCodeAt(0)] = 63;
114099function getLens(b64) {
114100 var len1 = b64.length;
114101 if (len1 % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
114102 // Trim off extra bytes after placeholder bytes are found
114103 // See: https://github.com/beatgammit/base64-js/issues/42
114104 var validLen = b64.indexOf("=");
114105 if (validLen === -1) validLen = len1;
114106 var placeHoldersLen = validLen === len1 ? 0 : 4 - validLen % 4;
114107 return [
114108 validLen,
114109 placeHoldersLen
114110 ];
114111}
114112// base64 is 4/3 + up to two characters of the original data
114113function byteLength(b64) {
114114 var lens = getLens(b64);

Callers 2

byteLengthFunction · 0.70
toByteArrayFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected