New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@allex/base64

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allex/base64 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

10

base64.d.ts

@@ -5,7 +5,7 @@ // Type definitions for @allex/base64

declare function encode(s: string, uriSafe?: boolean): string;
declare function decode(base64: string): string;
declare function encodeURI(s: string): string;
export declare function encode(s: string, uriSafe?: boolean): string;
export declare function decode(base64: string): string;
export declare function encodeURI(s: string): string;
declare function toUtf8(s: string): Buffer;
declare function fromUtf8(s: string): Buffer;
export declare function toUtf8(s: string): Buffer;
export declare function fromUtf8(s: string): Buffer;

@@ -9,125 +9,3 @@ /*!

*/
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('');
var charCode = String.fromCharCode;
var alphabetDic = null;
var toUtf8 = function (s) {
var position = -1;
var len = s.length;
var chr;
var buffer = [];
if (/^[\x00-\x7f]*$/.test(s)) {
while (++position < len) {
buffer.push(s.charCodeAt(position));
}
} else {
while (++position < len) {
chr = s.charCodeAt(position);
if (chr < 128) buffer.push(chr);else if (chr < 2048) buffer.push(chr >> 6 | 192, chr & 63 | 128);else buffer.push(chr >> 12 | 224, chr >> 6 & 63 | 128, chr & 63 | 128);
}
}
return buffer;
};
var fromUtf8 = function (s) {
var buffer = [];
var enc = new Array(4);
var position = -1;
var len;
if (!alphabetDic) {
len = alphabet.length;
alphabetDic = {};
while (++position < len) {
alphabetDic[alphabet[position]] = position;
}
position = -1;
}
len = s.length;
while (++position < len) {
enc[0] = alphabetDic[s.charAt(position)];
enc[1] = alphabetDic[s.charAt(++position)];
buffer.push(enc[0] << 2 | enc[1] >> 4);
enc[2] = alphabetDic[s.charAt(++position)];
if (enc[2] === 64) break;
buffer.push((enc[1] & 15) << 4 | enc[2] >> 2);
enc[3] = alphabetDic[s.charAt(++position)];
if (enc[3] === 64) break;
buffer.push((enc[2] & 3) << 6 | enc[3]);
}
return buffer;
};
var _encode = function (s) {
var buffer = toUtf8(s);
var len = buffer.length;
var nan0;
var nan1;
var nan2;
var enc = new Array(4);
var result = '';
var position = -1;
while (++position < len) {
nan0 = buffer[position];
nan1 = buffer[++position];
enc[0] = nan0 >> 2;
enc[1] = (nan0 & 3) << 4 | nan1 >> 4;
if (isNaN(nan1)) enc[2] = enc[3] = 64;else {
nan2 = buffer[++position];
enc[2] = (nan1 & 15) << 2 | nan2 >> 6;
enc[3] = isNaN(nan2) ? 64 : nan2 & 63;
}
result += alphabet[enc[0]] + alphabet[enc[1]] + alphabet[enc[2]] + alphabet[enc[3]];
}
return result;
};
var _decode = function (s) {
s = s.replace(/\s/g, '');
if (s.length % 4) throw new Error('InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.');
if (/[^A-Za-z0-9+/=\s]/g.test(s)) throw new Error('InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.');
var buffer = fromUtf8(s);
var len = buffer.length;
var position = 0;
var result = '';
while (position < len) {
if (buffer[position] < 128) result += charCode(buffer[position++]);else if (buffer[position] > 191 && buffer[position] < 224) result += charCode((buffer[position++] & 31) << 6 | buffer[position++] & 63);else result += charCode((buffer[position++] & 15) << 12 | (buffer[position++] & 63) << 6 | buffer[position++] & 63);
}
return result;
};
var encode = function (u, urisafe) {
return !urisafe ? _encode(String(u)) : _encode(String(u)).replace(/[+\/]/g, function (m0) {
return m0 === '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function (u) {
return encode(u, true);
};
var decode = function (a) {
a = String(a);
var pad = a.length % 4;
if (pad) {
a += Array(5 - pad).join('=');
}
return _decode(a.replace(/[-_]/g, function (m0) {
return m0 === '-' ? '+' : '/';
}).replace(/[^A-Za-z0-9=\+\/]/g, ''));
};
export { encode, decode, encodeURI, toUtf8, fromUtf8 };
var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),e=String.fromCharCode,n=null,t=function(r){var e,n=-1,t=r.length,a=[];if(/^[\x00-\x7f]*$/.test(r))for(;++n<t;)a.push(r.charCodeAt(n));else for(;++n<t;)(e=r.charCodeAt(n))<128?a.push(e):e<2048?a.push(e>>6|192,63&e|128):a.push(e>>12|224,e>>6&63|128,63&e|128);return a},a=function(e){var t,a=[],o=new Array(4),i=-1;if(!n){for(t=r.length,n={};++i<t;)n[r[i]]=i;i=-1}for(t=e.length;++i<t&&(o[0]=n[e.charAt(i)],o[1]=n[e.charAt(++i)],a.push(o[0]<<2|o[1]>>4),o[2]=n[e.charAt(++i)],64!==o[2])&&(a.push((15&o[1])<<4|o[2]>>2),o[3]=n[e.charAt(++i)],64!==o[3]);)a.push((3&o[2])<<6|o[3]);return a},o=function(e){for(var n,a,o,i=t(e),c=i.length,h=new Array(4),u="",f=-1;++f<c;)n=i[f],a=i[++f],h[0]=n>>2,h[1]=(3&n)<<4|a>>4,isNaN(a)?h[2]=h[3]=64:(o=i[++f],h[2]=(15&a)<<2|o>>6,h[3]=isNaN(o)?64:63&o),u+=r[h[0]]+r[h[1]]+r[h[2]]+r[h[3]];return u},i=function(r,e){return e?o(String(r)).replace(/[+\/]/g,(function(r){return"+"===r?"-":"_"})).replace(/=/g,""):o(String(r))},c=function(r){return i(r,!0)},h=function(r){var n=(r=String(r)).length%4;return n&&(r+=Array(5-n).join("=")),function(r){if((r=r.replace(/\s/g,"")).length%4)throw new Error("InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.");if(/[^A-Za-z0-9+/=\s]/g.test(r))throw new Error("InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.");for(var n=a(r),t=n.length,o=0,i="";o<t;)n[o]<128?i+=e(n[o++]):n[o]>191&&n[o]<224?i+=e((31&n[o++])<<6|63&n[o++]):i+=e((15&n[o++])<<12|(63&n[o++])<<6|63&n[o++]);return i}(r.replace(/[-_]/g,(function(r){return"-"===r?"+":"/"})).replace(/[^A-Za-z0-9=\+\/]/g,""))};export{h as decode,i as encode,c as encodeURI,a as fromUtf8,t as toUtf8};
/* f413ae216e073bb327c47f35bf6c6754 */

@@ -9,139 +9,3 @@ /*!

*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.Base64 = {}));
}(this, function (exports) { 'use strict';
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('');
var charCode = String.fromCharCode;
var alphabetDic = null;
var toUtf8 = function (s) {
var position = -1;
var len = s.length;
var chr;
var buffer = [];
if (/^[\x00-\x7f]*$/.test(s)) {
while (++position < len) {
buffer.push(s.charCodeAt(position));
}
} else {
while (++position < len) {
chr = s.charCodeAt(position);
if (chr < 128) buffer.push(chr);else if (chr < 2048) buffer.push(chr >> 6 | 192, chr & 63 | 128);else buffer.push(chr >> 12 | 224, chr >> 6 & 63 | 128, chr & 63 | 128);
}
}
return buffer;
};
var fromUtf8 = function (s) {
var buffer = [];
var enc = new Array(4);
var position = -1;
var len;
if (!alphabetDic) {
len = alphabet.length;
alphabetDic = {};
while (++position < len) {
alphabetDic[alphabet[position]] = position;
}
position = -1;
}
len = s.length;
while (++position < len) {
enc[0] = alphabetDic[s.charAt(position)];
enc[1] = alphabetDic[s.charAt(++position)];
buffer.push(enc[0] << 2 | enc[1] >> 4);
enc[2] = alphabetDic[s.charAt(++position)];
if (enc[2] === 64) break;
buffer.push((enc[1] & 15) << 4 | enc[2] >> 2);
enc[3] = alphabetDic[s.charAt(++position)];
if (enc[3] === 64) break;
buffer.push((enc[2] & 3) << 6 | enc[3]);
}
return buffer;
};
var _encode = function (s) {
var buffer = toUtf8(s);
var len = buffer.length;
var nan0;
var nan1;
var nan2;
var enc = new Array(4);
var result = '';
var position = -1;
while (++position < len) {
nan0 = buffer[position];
nan1 = buffer[++position];
enc[0] = nan0 >> 2;
enc[1] = (nan0 & 3) << 4 | nan1 >> 4;
if (isNaN(nan1)) enc[2] = enc[3] = 64;else {
nan2 = buffer[++position];
enc[2] = (nan1 & 15) << 2 | nan2 >> 6;
enc[3] = isNaN(nan2) ? 64 : nan2 & 63;
}
result += alphabet[enc[0]] + alphabet[enc[1]] + alphabet[enc[2]] + alphabet[enc[3]];
}
return result;
};
var _decode = function (s) {
s = s.replace(/\s/g, '');
if (s.length % 4) throw new Error('InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.');
if (/[^A-Za-z0-9+/=\s]/g.test(s)) throw new Error('InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.');
var buffer = fromUtf8(s);
var len = buffer.length;
var position = 0;
var result = '';
while (position < len) {
if (buffer[position] < 128) result += charCode(buffer[position++]);else if (buffer[position] > 191 && buffer[position] < 224) result += charCode((buffer[position++] & 31) << 6 | buffer[position++] & 63);else result += charCode((buffer[position++] & 15) << 12 | (buffer[position++] & 63) << 6 | buffer[position++] & 63);
}
return result;
};
var encode = function (u, urisafe) {
return !urisafe ? _encode(String(u)) : _encode(String(u)).replace(/[+\/]/g, function (m0) {
return m0 === '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function (u) {
return encode(u, true);
};
var decode = function (a) {
a = String(a);
var pad = a.length % 4;
if (pad) {
a += Array(5 - pad).join('=');
}
return _decode(a.replace(/[-_]/g, function (m0) {
return m0 === '-' ? '+' : '/';
}).replace(/[^A-Za-z0-9=\+\/]/g, ''));
};
exports.encode = encode;
exports.decode = decode;
exports.encodeURI = encodeURI;
exports.toUtf8 = toUtf8;
exports.fromUtf8 = fromUtf8;
Object.defineProperty(exports, '__esModule', { value: true });
}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).Base64={})}(this,(function(e){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),n=String.fromCharCode,t=null,o=function(e){var r,n=-1,t=e.length,o=[];if(/^[\x00-\x7f]*$/.test(e))for(;++n<t;)o.push(e.charCodeAt(n));else for(;++n<t;)(r=e.charCodeAt(n))<128?o.push(r):r<2048?o.push(r>>6|192,63&r|128):o.push(r>>12|224,r>>6&63|128,63&r|128);return o},i=function(e){var n,o=[],i=new Array(4),a=-1;if(!t){for(n=r.length,t={};++a<n;)t[r[a]]=a;a=-1}for(n=e.length;++a<n&&(i[0]=t[e.charAt(a)],i[1]=t[e.charAt(++a)],o.push(i[0]<<2|i[1]>>4),i[2]=t[e.charAt(++a)],64!==i[2])&&(o.push((15&i[1])<<4|i[2]>>2),i[3]=t[e.charAt(++a)],64!==i[3]);)o.push((3&i[2])<<6|i[3]);return o},a=function(e){for(var n,t,i,a=o(e),c=a.length,f=new Array(4),u="",s=-1;++s<c;)n=a[s],t=a[++s],f[0]=n>>2,f[1]=(3&n)<<4|t>>4,isNaN(t)?f[2]=f[3]=64:(i=a[++s],f[2]=(15&t)<<2|i>>6,f[3]=isNaN(i)?64:63&i),u+=r[f[0]]+r[f[1]]+r[f[2]]+r[f[3]];return u},c=function(e,r){return r?a(String(e)).replace(/[+\/]/g,(function(e){return"+"===e?"-":"_"})).replace(/=/g,""):a(String(e))};e.decode=function(e){var r=(e=String(e)).length%4;return r&&(e+=Array(5-r).join("=")),function(e){if((e=e.replace(/\s/g,"")).length%4)throw new Error("InvalidLengthError: decode failed: The string to be decoded is not the correct length for a base64 encoded string.");if(/[^A-Za-z0-9+/=\s]/g.test(e))throw new Error("InvalidCharacterError: decode failed: The string contains characters invalid in a base64 encoded string.");for(var r=i(e),t=r.length,o=0,a="";o<t;)r[o]<128?a+=n(r[o++]):r[o]>191&&r[o]<224?a+=n((31&r[o++])<<6|63&r[o++]):a+=n((15&r[o++])<<12|(63&r[o++])<<6|63&r[o++]);return a}(e.replace(/[-_]/g,(function(e){return"-"===e?"+":"/"})).replace(/[^A-Za-z0-9=\+\/]/g,""))},e.encode=c,e.encodeURI=function(e){return c(e,!0)},e.fromUtf8=i,e.toUtf8=o,Object.defineProperty(e,"__esModule",{value:!0})}));
/* f80d3b81ff881ec2f0788fd5f84e1cf9 */
{
"name": "@allex/base64",
"version": "1.0.1",
"version": "1.0.2",
"description": "Lightweight performance optimized base64 library by Allex",

@@ -23,3 +23,3 @@ "jsnext:main": "lib/base64.esm.js",

"lint": "eslint . --fix",
"build": "npm run lint && rollup-worker -c",
"build": "npm run lint && rb -c",
"prepare": "npm run build"

@@ -46,3 +46,2 @@ },

"jest": "^23.6.0",
"rollup-plugin-babel": "latest",
"rollup-worker": "next"

@@ -49,0 +48,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc