1.0.4 • Published 7 years ago

any2buffer v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

any2buffer NPM version js-standard-style

Pass anything, get Node buffer back

  • Note - If no encoding is passed and we can't guess the encoding we'll use fs to see if it's a file path. Obviously this will affect performance, so if you know what encoding it is or it is something we can assert (base64 or hex) then you can avoid touching the file system.

  • Other note - If no encoding is given, we can't assert the encoding, and it's not a valid file path then we will default the buffer to UTF-8. Pull requests for other encoding assertions are welcome, currently we only assert base64 and hex.

install

$ npm install --save any2buffer

api

usage

const any2buffer = require('any2buffer')
const doSomethingWithBuffer = (buf) => console.log(buf.toString('utf8'))

any2buffer('hello').then(doSomethingWithBuffer).catch(console.error)

License

MIT © Andrew Carpenter

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago