🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

js-base64

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-base64 - npm Package Compare versions

Comparing version
3.8.1
to
3.9.0
+2
-2
base64.d.mts

@@ -12,7 +12,7 @@ /**

*/
declare const version = "3.8.1";
declare const version = "3.9.0";
/**
* @deprecated use lowercase `version`.
*/
declare const VERSION = "3.8.1";
declare const VERSION = "3.9.0";
/**

@@ -19,0 +19,0 @@ * polyfill version of `btoa`

@@ -12,7 +12,7 @@ /**

*/
declare const version = "3.8.1";
declare const version = "3.9.0";
/**
* @deprecated use lowercase `version`.
*/
declare const VERSION = "3.8.1";
declare const VERSION = "3.9.0";
/**

@@ -19,0 +19,0 @@ * polyfill version of `btoa`

+18
-33

@@ -40,3 +40,3 @@ //

*/
var version = '3.8.1';
var version = '3.9.0';
/**

@@ -46,3 +46,2 @@ * @deprecated use lowercase `version`.

var VERSION = version;
var _hasBuffer = typeof Buffer === 'function';
var _TD = typeof TextDecoder === 'function' ? new TextDecoder('utf-8', { ignoreBOM: true }) : undefined;

@@ -91,19 +90,12 @@ var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;

var _btoa = typeof btoa === 'function' ? function (bin) { return btoa(bin); }
: _hasBuffer ? function (bin) {
if (/[^\x00-\xff]/.test(bin))
throw new TypeError('invalid character found');
return Buffer.from(bin, 'binary').toString('base64');
: btoaPolyfill;
var _fromUint8Array = function (u8a) {
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
var maxargs = 0x1000;
var strs = [];
for (var i = 0, l = u8a.length; i < l; i += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
}
: btoaPolyfill;
var _fromUint8Array = _hasBuffer
? function (u8a) { return Buffer.from(u8a).toString('base64'); }
: function (u8a) {
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
var maxargs = 0x1000;
var strs = [];
for (var i = 0, l = u8a.length; i < l; i += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
}
return _btoa(strs.join(''));
};
return _btoa(strs.join(''));
};
/**

@@ -149,7 +141,5 @@ * converts a Uint8Array to a Base64 string.

//
var _encode = _hasBuffer
? function (s) { return Buffer.from(s, 'utf8').toString('base64'); }
: _TE
? function (s) { return _fromUint8Array(_TE.encode(s)); }
: function (s) { return _btoa(utob(s)); };
var _encode = _TE
? function (s) { return _fromUint8Array(_TE.encode(s)); }
: function (s) { return _btoa(utob(s)); };
/**

@@ -233,8 +223,5 @@ * converts a UTF-8-encoded string to a Base64 string.

var _atob = typeof atob === 'function' ? function (asc) { return atob(_tidyB64(asc)); }
: _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
: atobPolyfill;
: atobPolyfill;
//
var _toUint8Array = _hasBuffer
? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
: function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); };
var _toUint8Array = function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); };
/**

@@ -245,7 +232,5 @@ * converts a Base64 string to a Uint8Array.

//
var _decode = _hasBuffer
? function (a) { return Buffer.from(a, 'base64').toString('utf8'); }
: _TD
? function (a) { return _TD.decode(_toUint8Array(a)); }
: function (a) { return btou(_atob(a)); };
var _decode = _TD
? function (a) { return _TD.decode(_toUint8Array(a)); }
: function (a) { return btou(_atob(a)); };
var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); };

@@ -252,0 +237,0 @@ /**

@@ -12,3 +12,3 @@ /**

*/
const version = '3.8.1';
const version = '3.9.0';
/**

@@ -18,3 +18,2 @@ * @deprecated use lowercase `version`.

const VERSION = version;
const _hasBuffer = typeof Buffer === 'function';
const _TD = typeof TextDecoder === 'function' ? new TextDecoder('utf-8', { ignoreBOM: true }) : undefined;

@@ -63,19 +62,12 @@ const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;

const _btoa = typeof btoa === 'function' ? (bin) => btoa(bin)
: _hasBuffer ? (bin) => {
if (/[^\x00-\xff]/.test(bin))
throw new TypeError('invalid character found');
return Buffer.from(bin, 'binary').toString('base64');
: btoaPolyfill;
const _fromUint8Array = (u8a) => {
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
const maxargs = 0x1000;
let strs = [];
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
}
: btoaPolyfill;
const _fromUint8Array = _hasBuffer
? (u8a) => Buffer.from(u8a).toString('base64')
: (u8a) => {
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
const maxargs = 0x1000;
let strs = [];
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
}
return _btoa(strs.join(''));
};
return _btoa(strs.join(''));
};
/**

@@ -118,7 +110,5 @@ * converts a Uint8Array to a Base64 string.

//
const _encode = _hasBuffer
? (s) => Buffer.from(s, 'utf8').toString('base64')
: _TE
? (s) => _fromUint8Array(_TE.encode(s))
: (s) => _btoa(utob(s));
const _encode = _TE
? (s) => _fromUint8Array(_TE.encode(s))
: (s) => _btoa(utob(s));
/**

@@ -199,8 +189,5 @@ * converts a UTF-8-encoded string to a Base64 string.

const _atob = typeof atob === 'function' ? (asc) => atob(_tidyB64(asc))
: _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
: atobPolyfill;
: atobPolyfill;
//
const _toUint8Array = _hasBuffer
? (a) => _U8Afrom(Buffer.from(a, 'base64'))
: (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0)));
const _toUint8Array = (a) => _U8Afrom(_atob(a).split('').map(c => c.charCodeAt(0)));
/**

@@ -211,7 +198,5 @@ * converts a Base64 string to a Uint8Array.

//
const _decode = _hasBuffer
? (a) => Buffer.from(a, 'base64').toString('utf8')
: _TD
? (a) => _TD.decode(_toUint8Array(a))
: (a) => btou(_atob(a));
const _decode = _TD
? (a) => _TD.decode(_toUint8Array(a))
: (a) => btou(_atob(a));
const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/'));

@@ -218,0 +203,0 @@ /**

{
"name": "js-base64",
"version": "3.8.1",
"version": "3.9.0",
"description": "Yet another Base64 transcoder in pure-JS",

@@ -5,0 +5,0 @@ "main": "base64.js",

@@ -29,3 +29,3 @@ [![CI via GitHub Actions](https://github.com/dankogai/js-base64/actions/workflows/node.js.yml/badge.svg)](https://github.com/dankogai/js-base64/actions/workflows/node.js.yml)

```html
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-base64@3.9.0/base64.min.js"></script>
```

@@ -53,3 +53,3 @@

// note jsdelivr.net does not automatically minify .mjs
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.mjs';
import { Base64 } from 'https://cdn.jsdelivr.net/npm/js-base64@3.9.0/base64.mjs';
</script>

@@ -61,3 +61,3 @@ ```

// or if you prefer no Base64 namespace
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.8.1/base64.mjs';
import { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.9.0/base64.mjs';
</script>

@@ -64,0 +64,0 @@ ```