comment on Uint8Array compat

Este commit está contenido en:
AJ ONeal 2018-12-01 20:35:31 -07:00
padre 96d47924bf
commit e3bc03d6a1
Se han modificado 1 ficheros con 4 adiciones y 4 borrados

Ver fichero

@ -1,24 +1,24 @@
'use strict'; '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; var Enc = module.exports;
Enc.base64ToBuf = function (str) { Enc.base64ToBuf = function (str) {
// node handles both base64 and urlBase64 equally
return Buffer.from(str, 'base64'); return Buffer.from(str, 'base64');
}; };
Enc.bufToBase64 = function (u8) { Enc.bufToBase64 = function (u8) {
// Ensure a node buffer, even if TypedArray
return Buffer.from(u8).toString('base64'); return Buffer.from(u8).toString('base64');
}; };
Enc.bufToBin = function (u8) { Enc.bufToBin = function (u8) {
// Ensure a node buffer, even if TypedArray
return Buffer.from(u8).toString('binary'); return Buffer.from(u8).toString('binary');
}; };
Enc.bufToHex = function (u8) { Enc.bufToHex = function (u8) {
// Ensure a node buffer, even if TypedArray
return Buffer.from(u8).toString('hex'); return Buffer.from(u8).toString('hex');
}; };