Git Product home page Git Product logo

buffy's Introduction

Description

Buffy is a utility module for node.js that lets you easily access and manipulate many Buffers as if they were one single Buffer.

Requirements

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: <Buffy 01 04 03 04 01 01 04 14 0a 0c 06 2c 09>

console.log(b.indexOf([1, 4]));
// output: 0

console.log(b.indexOf([1, 4], 1));
// output: 5

console.log(b.indexOf([1, 4, 20, 10, 12, 6]));
// output: 5

console.log(b.indexOf([44, 9]));
// output: 11

var myBuffer = new Buffer(5);
b.copy(myBuffer, 0, 7, 12);
console.log(inspect(myBuffer));
// output: <Buffer 14 0a 0c 06 2c>

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.

buffy's People

Contributors

mscdex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kalikex1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.