Created
March 26, 2018 15:25
-
-
Save chrisabrams/3e0306a85e362501f757ed192d2b682d to your computer and use it in GitHub Desktop.
Basic buffer stuff for Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertTo(type, data) { | |
switch(type) { | |
case 'hex': | |
case 'string': | |
return Buffer.from(data).toString('hex') | |
case 'buffer': | |
case 'Uint8Array': | |
return Buffer.from(data, 'hex') | |
} | |
} | |
module.exports = convertTo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment