Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mscdex/buffy
Access and manipulate multiple node.js Buffers as if they were one continuous Buffer
https://github.com/mscdex/buffy
Last synced: 3 months ago
JSON representation
Access and manipulate multiple node.js Buffers as if they were one continuous Buffer
- Host: GitHub
- URL: https://github.com/mscdex/buffy
- Owner: mscdex
- License: mit
- Created: 2011-04-12T04:12:18.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-04-17T17:24:45.000Z (over 13 years ago)
- Last Synced: 2023-04-09T07:16:24.342Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Description
===========Buffy is a utility module for [node.js](http://nodejs.org/) that lets you easily access and manipulate many Buffers as if they were one single Buffer.
Requirements
============* [node.js](http://nodejs.org/) -- v0.4.0 or newer
Examples
========var Buffy = require('./buffy'), inspect = require('util').inspect;
var b = new Buffy();
b.append(new Buffer([1, 4, 3, 4, 1, 1, 4]));
b.append(new Buffer([20, 10, 12]));
b.append(new Buffer([6]));
b.append(new Buffer([44, 9]));console.log(inspect(b));
// output:console.log(b.indexOf([1, 4]));
// output: 0console.log(b.indexOf([1, 4], 1));
// output: 5console.log(b.indexOf([1, 4, 20, 10, 12, 6]));
// output: 5
console.log(b.indexOf([44, 9]));
// output: 11var myBuffer = new Buffer(5);
b.copy(myBuffer, 0, 7, 12);
console.log(inspect(myBuffer));
// output:API
===_Properties_
------------* **length** - Returns the total length of the contents of the Buffy
_Methods_
---------* **(constructor)**() - Creates and returns a new instance of a Buffy object.
* **get**(Integer:index) - _Boolean/Integer:byte_ - Retrieves a single byte at the specified index. If the index is invalid, Boolean false is returned.
* **set**(Integer:index, Integer:newByteValue) - _Boolean:success_ - Sets the byte at the specified index to the given value.
* **indexOf**(Array:bytes, [Integer:start=0]) - _Integer:position_ - Searches for the specified bytes in the Buffy at an optional starting position. Returns -1 if the bytes were not found.
* **copy**(Buffer:destBuffer, [Integer:destStart=0], [Integer:sourceStart=0], [Integer:sourceEnd=buffy.length]) - _(void)_ - Works similar to Buffer's copy().
* **append**(Buffer:newBuffer) - _(void)_ - Appends the given Buffer to the end of the Buffy.
* **GCBefore**(Integer:index) - _Integer:bytesRemoved_ - Removes any Buffers stored before the given Buffy index.
* **toString**([String:encoding], [Integer:startIndex], [Integer:endIndex]) - _String:result_ - Decodes and returns a string with the specified encoding beginning at startIndex and ending at endIndex.