miguelmota / any-to-buffer

Convert values to Buffer

Home Page:https://github.com/miguelmota/any-to-buffer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Convert values to Buffer

https://github.com/miguelmota/any-to-buffer

License:MIT License


Languages

Language:JavaScript 100.0%