any-to-buffer
v0.0.2
Published
Convert values to Buffer
Downloads
2
Maintainers
Readme
any-to-buffer
Convert values to Buffer
Install
npm install any-to-buffer
Getting started
const toBuffer = require('any-to-buffer')
const BN = require('bn.js')
console.log(toBuffer(256)) // <Buffer 01 00>
console.log(toBuffer(256, { size: 3 })) // <Buffer 00 01 00>
console.log(toBuffer('0x010203')) // <Buffer 01 02 03>
console.log(toBuffer('abc')) // <Buffer 61 62 63>
console.log(toBuffer(Buffer.from('abc'))) // <Buffer 61 62 63>
console.log(toBuffer(new BN(256))) // <Buffer 01 00>
Test
npm test