Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@endo/base64

Package Overview
Dependencies
Maintainers
5
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@endo/base64 - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

./index.js

7

package.json
{
"name": "@endo/base64",
"version": "1.0.1",
"version": "1.0.2",
"description": "Transcodes base64",

@@ -15,3 +15,4 @@ "keywords": [

"type": "git",
"url": "git+https://github.com/endojs/endo.git"
"url": "git+https://github.com/endojs/endo.git",
"directory": "packages/base64"
},

@@ -80,3 +81,3 @@ "bugs": {

},
"gitHead": "373f9eebab66c94ed42350473c90fb25e6054f0a"
"gitHead": "f731c5c12f8d185dbf2daf53ec6a57e5ac56e4e9"
}

@@ -0,19 +1,4 @@

export function jsDecodeBase64(string: string, name?: string | undefined): Uint8Array;
/** @type {typeof jsDecodeBase64} */
export const decodeBase64: typeof jsDecodeBase64;
/**
* Decodes a Base64 string into bytes, as specified in
* https://tools.ietf.org/html/rfc4648#section-4
*
* XSnap is a JavaScript engine based on Moddable/XS.
* The algorithm below is orders of magnitude too slow on this VM, but it
* arranges a native binding on the global object.
* We use that if it is available instead.
*
* @param {string} string Base64-encoded string
* @param {string} [name] The name of the string as it will appear in error
* messages.
* @returns {Uint8Array} decoded bytes
*/
declare function jsDecodeBase64(string: string, name?: string | undefined): Uint8Array;
export {};
//# sourceMappingURL=decode.d.ts.map

@@ -16,2 +16,5 @@ // @ts-check

*
* This function is exported from this *file* for use in benchmarking,
* but is not part of the *module*'s public API.
*
* @param {string} string Base64-encoded string

@@ -22,3 +25,3 @@ * @param {string} [name] The name of the string as it will appear in error

*/
const jsDecodeBase64 = (string, name = '<unknown>') => {
export const jsDecodeBase64 = (string, name = '<unknown>') => {
const data = new Uint8Array(Math.ceil((string.length * 4) / 3));

@@ -46,8 +49,10 @@ let register = 0;

while (i < string.length && quantum % 8 !== 0) {
if (string[i] !== padding) {
while (quantum > 0) {
if (i === string.length || string[i] !== padding) {
throw Error(`Missing padding at offset ${i} of string ${name}`);
}
// We MAY reject non-zero padding bits, but choose not to.
// https://datatracker.ietf.org/doc/html/rfc4648#section-3.5
i += 1;
quantum += 6;
quantum -= 2;
}

@@ -54,0 +59,0 @@

@@ -0,17 +1,4 @@

export function jsEncodeBase64(data: Uint8Array): string;
/** @type {typeof jsEncodeBase64} */
export const encodeBase64: typeof jsEncodeBase64;
/**
* Encodes bytes into a Base64 string, as specified in
* https://tools.ietf.org/html/rfc4648#section-4
*
* XSnap is a JavaScript engine based on Moddable/XS.
* The algorithm below is orders of magnitude too slow on this VM, but it
* arranges a native binding on the global object.
* We use that if it is available instead.
*
* @param {Uint8Array} data
* @returns {string} base64 encoding
*/
declare function jsEncodeBase64(data: Uint8Array): string;
export {};
//# sourceMappingURL=encode.d.ts.map

@@ -16,6 +16,9 @@ // @ts-check

*
* This function is exported from this *file* for use in benchmarking,
* but is not part of the *module*'s public API.
*
* @param {Uint8Array} data
* @returns {string} base64 encoding
*/
const jsEncodeBase64 = data => {
export const jsEncodeBase64 = data => {
// A cursory benchmark shows that string concatenation is about 25% faster

@@ -22,0 +25,0 @@ // than building an array and joining it in v8, in 2020, for strings of about

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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