Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/stringify-buffer
Converts a buffer a collection of strings, one for each possible encoding.
https://github.com/thlorenz/stringify-buffer
Last synced: 24 days ago
JSON representation
Converts a buffer a collection of strings, one for each possible encoding.
- Host: GitHub
- URL: https://github.com/thlorenz/stringify-buffer
- Owner: thlorenz
- License: mit
- Created: 2017-01-25T20:23:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-25T21:53:04.000Z (almost 8 years ago)
- Last Synced: 2024-10-23T06:15:47.692Z (2 months ago)
- Language: JavaScript
- Homepage: https://thlorenz.github.io/stringify-buffer
- Size: 1.13 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stringify-buffer [![build status](https://secure.travis-ci.org/thlorenz/stringify-buffer.png)](http://travis-ci.org/thlorenz/stringify-buffer)
Converts a buffer a collection of strings, one for each possible encoding.
```js
const stringify = require('stringify-buffer')
const buf = Buffer.from('Hello ☃')
console.log(stringify(buf))
```{ ascii: 'Hello b\u0018\u0003',
utf8: 'Hello ☃',
utf16le: '效汬飢',
binary: 'Hello â',
base64: 'SGVsbG8g4piD',
hex: '48656c6c6f20e29883' }## Installation
npm install stringify-buffer
## [API](https://thlorenz.github.io/stringify-buffer)
### stringifyBuffer
Stringifies the given buffer once for each encoding and adds
the result a hash.**Parameters**
- `buf` **[Buffer](https://nodejs.org/api/buffer.html)** the buffer to stringify
- `encodings` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>?** the encodings to be used, if not supplied [all valid
encodings](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) are usedReturns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** a hash with a string value of the buffer for each of the supplied encodings
### stringifyBuffer.encodings
Returns an array of all valid Buffer encodings that are supported.
This is the same array that is used if no `encodings` is passed to @see stringifyBuffers.Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** all valid Buffer encodings
## License
MIT