<commit_before># node-buffertools

Utilities for manipulating buffers.

## Installing the module

Easy.

	node-waf configure build install

Now you can include the module in your project.

	var buffertools = require('buffertools');
	buffertools.clear(buf);

## Methods

The API is still in flux but here are the goodies so far.

### buffertools.clear(buffer)

Clear the buffer. This is equivalent to `buffertools.fill(buffer, 0)`.
Returns the buffer object so you can chain calls.

### buffertools.fill(buffer, integer|string|buffer)

Fill the buffer (repeatedly if necessary) with the second argument.
Returns the buffer object so you can chain calls.

### buffertools.equals(a, b)

Returns true if the first buffer equals the second one, false otherwise.

Buffers are considered equal when they are of the same length and contain
the same binary data.

Caveat emptor: If you store strings with different character encodings
in the buffers, they will most likely *not* be equal.

### buffertools.compare(a, b)

Lexicographically compare two buffers. Returns a number smaller than 1
if a < b, zero if a == b or a number larger than 1 if a > b.

Buffers are considered equal when they are of the same length and contain
the same binary data.

Smaller buffers are considered to be less than larger ones. This has hurt
some buffers' feelings.

## TODO

* Extend Buffer.prototype with buffertools methods.
* Logical operations on buffers (AND, OR, XOR).
* Add indexOf() and lastIndexOf() functions.
* bin2hex and hex2bin functionality.<commit_msg>Update TODO.<commit_after># node-buffertools

Utilities for manipulating buffers.

## Installing the module

Easy.

	node-waf configure build install

Now you can include the module in your project.

	var buffertools = require('buffertools');
	buffertools.clear(buf);

## Methods

The API is still in flux but here are the goodies so far.

### buffertools.clear(buffer)

Clear the buffer. This is equivalent to `buffertools.fill(buffer, 0)`.
Returns the buffer object so you can chain calls.

### buffertools.fill(buffer, integer|string|buffer)

Fill the buffer (repeatedly if necessary) with the second argument.
Returns the buffer object so you can chain calls.

### buffertools.equals(a, b)

Returns true if the first buffer equals the second one, false otherwise.

Buffers are considered equal when they are of the same length and contain
the same binary data.

Caveat emptor: If you store strings with different character encodings
in the buffers, they will most likely *not* be equal.

### buffertools.compare(a, b)

Lexicographically compare two buffers. Returns a number smaller than 1
if a < b, zero if a == b or a number larger than 1 if a > b.

Buffers are considered equal when they are of the same length and contain
the same binary data.

Smaller buffers are considered to be less than larger ones. This has hurt
some buffers' feelings.

## TODO

* Buffers and strings should mostly be interchangeable as arguments to methods.
* Extend Buffer.prototype with buffertools methods.
* Logical operations on buffers (AND, OR, XOR).
* Add indexOf() and lastIndexOf() functions.
* bin2hex and hex2bin functionality.
{'fraction_non_alphanumeric': 0.06666666666666667, 'fraction_numerical': 0.00315955766192733, 'mean_word_length': 4.421232876712328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3537201', 'n_tokens_mistral': 862, 'n_tokens_neox': 862, 'n_words': 441}