0.0.1 • Published 6 years ago

unbuffer v0.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

unbuffer

Interpret Buffer strings generated by NodeJS util.inspect.

Installation

With npm:

$ npm install unbuffer

Usage

Module exports a single function unbuffer which accepts a string and generates an object with the following keys:

  • partial: true if the Buffer is a partial representation (marked with ...)
  • data: a Buffer object whose data matches the string representation
> var unbuffer = require("./");

> unbuffer("<Buffer 00 11>")
{ partial: false, data: <Buffer 00 11> }

> unbuffer("<Buffer 00 11 22 ...>");
{ partial: true, data: <Buffer 00 11 22> }

The key invariant can be stated in two ways:

util.inspect(unbuffer(str).data) == str.replace(/ \.\.\./,"")

unbuffer(util.inspect(buf)).data.compare(buf.slice(0, require('buffer').INSPECT_MAX_BYTES)) == 0

License

Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 License are reserved by the Original Author.

Analytics

0.0.1

6 years ago