Wondering what’s next for npm?Check out our public roadmap! »

any-to-buffer

0.0.2 • Public • Published

any-to-buffer

Convert values to Buffer

License NPM version

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

License

MIT

Install

npm i any-to-buffer

DownloadsWeekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

5.52 kB

Total Files

6

Last publish

Collaborators

  • avatar