https://github.com/tapjs/buffer-to-string
A better Buffer.toString()
https://github.com/tapjs/buffer-to-string
Last synced: about 1 year ago
JSON representation
A better Buffer.toString()
- Host: GitHub
- URL: https://github.com/tapjs/buffer-to-string
- Owner: tapjs
- License: other
- Created: 2016-01-16T07:32:59.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-02-26T19:00:35.000Z (over 4 years ago)
- Last Synced: 2025-04-23T22:05:58.415Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/buffer-to-string
- Size: 5.86 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# buffer-to-string [](https://travis-ci.org/tapjs/buffer-to-string)
> A better Buffer.toString()
Displays buffer content in hex. Characters are grouped into two-character bytes, with a customizable line wrap width.
## Install
```
$ npm install --save buffer-to-string
```
## Usage
```js
const bufferToString = require('buffer-to-string');
bufferToString(new Buffer([0, 1, 2, 3, 4, 5, 6]), 3);
/*
00 01 02
03 04 05
06
*/
```
## API
### bufferToString(buffer, [width])
#### input
Type: `Buffer`
The Buffer to stringify.
#### width
Type: `number`
Default: `20`
The maximum width before wrapping a newline. It is measured in bytes displayed. The maximum character width can be determined by computing `(3 * width) - 1`.
## License
MIT © [Isaac Z. Schlueter](http://github.com/isaacs), [James Talmage](http://github.com/jamestalmage)