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

@hexagon/base64

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hexagon/base64 - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

2

dist/base64.min.js

@@ -1,1 +0,1 @@

(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.base64=factory())})(this,function(){"use strict";const chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",charsUrl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",genLookup=target=>{let lookupTemp=typeof Uint8Array==="undefined"?[]:new Uint8Array(256);for(let i=0;i<chars.length;i++){lookupTemp[target.charCodeAt(i)]=i}return lookupTemp},lookup=genLookup(chars),lookupUrl=genLookup(charsUrl);let base64={};base64.toArrayBuffer=(data,urlMode)=>{let bufferLength=data.length*.75,len=data.length,i,p=0,encoded1,encoded2,encoded3,encoded4;if(data[data.length-1]==="="){bufferLength--;if(data[data.length-2]==="="){bufferLength--}}const arraybuffer=new ArrayBuffer(bufferLength),bytes=new Uint8Array(arraybuffer),target=urlMode?lookupUrl:lookup;for(i=0;i<len;i+=4){encoded1=target[data.charCodeAt(i)];encoded2=target[data.charCodeAt(i+1)];encoded3=target[data.charCodeAt(i+2)];encoded4=target[data.charCodeAt(i+3)];bytes[p++]=encoded1<<2|encoded2>>4;bytes[p++]=(encoded2&15)<<4|encoded3>>2;bytes[p++]=(encoded3&3)<<6|encoded4&63}return bytes};base64.fromArrayBuffer=(arrBuf,urlMode)=>{let bytes=new Uint8Array(arrBuf),i,len=bytes.length,result="",target=urlMode?charsUrl:chars;for(i=0;i<len;i+=3){result+=target[bytes[i]>>2];result+=target[(bytes[i]&3)<<4|bytes[i+1]>>4];result+=target[(bytes[i+1]&15)<<2|bytes[i+2]>>6];result+=target[bytes[i+2]&63]}if(len%3===2){result=result.substring(0,result.length-1)+(urlMode?"":"=")}else if(len%3===1){result=result.substring(0,result.length-2)+(urlMode?"":"==")}return result};base64.toString=(str,urlMode)=>{return Buffer.from(base64.toArrayBuffer(str,urlMode)).toString()};base64.fromString=(str,urlMode)=>{return base64.fromArrayBuffer(Buffer.from(str),urlMode)};return base64});
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.base64=factory())})(this,function(){"use strict";const chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",charsUrl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",genLookup=target=>{let lookupTemp=typeof Uint8Array==="undefined"?[]:new Uint8Array(256);for(let i=0;i<chars.length;i++){lookupTemp[target.charCodeAt(i)]=i}return lookupTemp},lookup=genLookup(chars),lookupUrl=genLookup(charsUrl);let base64={};base64.toArrayBuffer=(data,urlMode)=>{let bufferLength=data.length*.75,len=data.length,i,p=0,encoded1,encoded2,encoded3,encoded4;if(data[data.length-1]==="="){bufferLength--;if(data[data.length-2]==="="){bufferLength--}}const arraybuffer=new ArrayBuffer(bufferLength),bytes=new Uint8Array(arraybuffer),target=urlMode?lookupUrl:lookup;for(i=0;i<len;i+=4){encoded1=target[data.charCodeAt(i)];encoded2=target[data.charCodeAt(i+1)];encoded3=target[data.charCodeAt(i+2)];encoded4=target[data.charCodeAt(i+3)];bytes[p++]=encoded1<<2|encoded2>>4;bytes[p++]=(encoded2&15)<<4|encoded3>>2;bytes[p++]=(encoded3&3)<<6|encoded4&63}return arraybuffer};base64.fromArrayBuffer=(arrBuf,urlMode)=>{let bytes=new Uint8Array(arrBuf),i,len=bytes.length,result="",target=urlMode?charsUrl:chars;for(i=0;i<len;i+=3){result+=target[bytes[i]>>2];result+=target[(bytes[i]&3)<<4|bytes[i+1]>>4];result+=target[(bytes[i+1]&15)<<2|bytes[i+2]>>6];result+=target[bytes[i+2]&63]}if(len%3===2){result=result.substring(0,result.length-1)+(urlMode?"":"=")}else if(len%3===1){result=result.substring(0,result.length-2)+(urlMode?"":"==")}return result};base64.toString=(str,urlMode)=>{return Buffer.from(base64.toArrayBuffer(str,urlMode)).toString()};base64.fromString=(str,urlMode)=>{return base64.fromArrayBuffer(Buffer.from(str),urlMode)};return base64});
{
"name": "@hexagon/base64",
"version": "0.0.10",
"version": "0.0.11",
"description": "Base64 and base64url to string or arraybuffer",

@@ -5,0 +5,0 @@ "author": "Hexagon <github.com/hexagon>",

@@ -91,3 +91,3 @@ /* ------------------------------------------------------------------------------------

return bytes;
return arraybuffer;

@@ -94,0 +94,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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