Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
browserify-unibabel
Advanced tools
Base64, TypedArrays, and UTF-8 / Unicode conversions in Browser (and Node) JavaScript
A simple browserify style version of Unibabel, exported as a module instead of as a global object.
Currently does not support the add-in support for hex or base32, because I didn't need them when I made this, and its extendable format is a little unusual. So, PRs welcome.
var Unibabel = require('unibabel-js')
// Now you can use Unibabel like the original docs below.
The original Unibabel fails hard when loaded into node.js, but this one doesn't. That's because I unit-test some things that include this in a node environment, even when not using it. I think the hard failure was a little extreme.
To reiterate the error: You shouldn't use this in node.js, you have Buffers in node.js, and they do this all better.
Minimalistic Base64, TypedArrays, and UTF-8 / Unicode conversions in Browser (and Node) JavaScript. Optional add-on support for hex and base32.
See https://coolaj86.com/articles/base64-unicode-utf-8-javascript-and-you/
See also
You SHOULD NOT use this module. You already have Buffer
and thirty-two
:
var buf = new Buffer('I ½ ♥ 💩', 'utf8');
buf.toString('hex');
buf.toString('base64');
buf.toString('ascii');
buf.toString('utf8');
buf.toString('binary'); // deprecated, do not use
// TypedArray <--> UTF8
var uint8Array = Unibabel.strToUtf8Arr(str);
var str = Unibabel.utf8ArrToStr(uint8Array);
// TypedArray <--> Base64
var base64 = Unibabel.arrToBase64(uint8Array)
var uint8Array = Unibabel.base64ToArr(base64)
Normal APIs
index.js
Hex APIs
unibabel.hex.js
Base32 APIs
unibabel.base32.js
Helper APIs
// Base64
var myArray = Unibabel.base64ToArr("QmFzZSA2NCDigJQgTW96aWxsYSBEZXZlbG9wZXIgTmV0d29yaw=="); // "Base 64 \u2014 Mozilla Developer Network"
var myBuffer = Unibabel.base64ToArr("QmFzZSA2NCDigJQgTW96aWxsYSBEZXZlbG9wZXIgTmV0d29yaw==").buffer; // "Base 64 \u2014 Mozilla Developer Network"
console.log(myBuffer.byteLength);
// Crazy Unicode
var sMyInput = "I'm a ☢ ☃ that plays 𝄢 guitar and spea̧͈͖ks Ar̽̾̈́͒͑ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜!";
var aMyUTF8Input = Unibabel.strToUtf8Arr(sMyInput);
var sMyBase64 = Unibabel.arrToBase64(aMyUTF8Input);
alert(sMyBase64);
var aMyUTF8Output = Unibabel.base64ToArr(sMyBase64);
var sMyOutput = Unibabel.utf8ArrToStr(aMyUTF8Output);
alert(sMyOutput);
index.js
and unibabel.hex.js
are dual-licensed as Apache 2.0 and MIT.unibabel.base32.js
is a modified version of thirty-two and is therefore licensed MIT.Some parts of the code were taken from MDN, which Mozilla has licensed in the Public Domain, which means that I am at liberty to re-license my copy under the Apache 2 and MIT licenses.
See https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses
Added unibabel.base32.js
The new implementation is binary compatible with node.js, TextEncoder, and other more-common UTF-8 encodings.
It is also based on DOM APIs which result in much less code and are still backwards compatible all the way back to IE6 (not on purpose, just that it happens to work).
See https://coolaj86.com/articles/base64-unicode-utf-8-javascript-and-you/
This version was based on the work by good folks at the MDN, however, the UTF-8 conversion was not byte-compatible with other UTF-8 conversions (such as node.js and TextEncoder), so don't use it. See https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
FAQs
Base64, TypedArrays, and UTF-8 / Unicode conversions in Browser (and Node) JavaScript
The npm package browserify-unibabel receives a total of 509 weekly downloads. As such, browserify-unibabel popularity was classified as not popular.
We found that browserify-unibabel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.