From e3bc03d6a1f1580b9e83bbca85a7632fe25f0669 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 1 Dec 2018 20:35:31 -0700 Subject: [PATCH] comment on Uint8Array compat --- lib/encoding.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/encoding.js b/lib/encoding.js index 8aabcca..da46725 100644 --- a/lib/encoding.js +++ b/lib/encoding.js @@ -1,24 +1,24 @@ 'use strict'; +// The purpose of this module is to abstract away +// the parts that aren't vanilla js (for easy portability) +// and to work with native JavaScript Uint8Arrays + var Enc = module.exports; Enc.base64ToBuf = function (str) { - // node handles both base64 and urlBase64 equally return Buffer.from(str, 'base64'); }; Enc.bufToBase64 = function (u8) { - // Ensure a node buffer, even if TypedArray return Buffer.from(u8).toString('base64'); }; Enc.bufToBin = function (u8) { - // Ensure a node buffer, even if TypedArray return Buffer.from(u8).toString('binary'); }; Enc.bufToHex = function (u8) { - // Ensure a node buffer, even if TypedArray return Buffer.from(u8).toString('hex'); };