Socket
Socket
Sign inDemoInstall

smart-buffer

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.4 to 1.1.15

lib/smart-buffer.js

17

package.json
{
"name": "smart-buffer",
"version": "1.1.4",
"version": "1.1.15",
"description": "A smarter Buffer that keeps track of its own read and write positions while growing endlessly.",
"main": "build/smartbuffer.js",
"main": "lib/smart-buffer.js",
"homepage": "https://github.com/JoshGlazebrook/smart-buffer/",

@@ -24,4 +24,4 @@ "repository": {

"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
"node": ">= 0.10.15",
"npm": ">= 1.3.5"
},

@@ -39,11 +39,8 @@ "author": "Josh Glazebrook",

"typings": "typings/index",
"dependencies": {
"@types/node": "^7.0.4"
},
"dependencies": {},
"scripts": {
"test": "mocha test/smartbuffer.test.js",
"test": "mocha test/smart-buffer.test.js",
"coverage": "istanbul cover node_modules/mocha/bin/_mocha recursive test",
"fullcoverage": "node_modules/.bin/istanbul -include-all-sources cover node_modules/mocha/bin/_mocha recursive test",
"prepublish": "tsc -p ./"
"fullcoverage": "node_modules/.bin/istanbul -include-all-sources cover node_modules/mocha/bin/_mocha recursive test"
}
}

@@ -17,9 +17,3 @@ smart-buffer [![Build Status](https://travis-ci.org/JoshGlazebrook/smart-buffer.svg?branch=master)](https://travis-ci.org/JoshGlazebrook/smart-buffer) [![Coverage Status](https://coveralls.io/repos/github/JoshGlazebrook/smart-buffer/badge.svg?branch=master)](https://coveralls.io/github/JoshGlazebrook/smart-buffer?branch=master)

* Allows for inserting values at specific points in the internal Buffer.
* Built in TypeScript
* Type Definitions Provided
Requirements:
* Node v4.0+ is supported at this time. (Versions prior to 2.0 will work on node 0.10)
#### Note:

@@ -32,6 +26,2 @@ smart-buffer can be used for writing to an underlying buffer as well as reading from it. It however does not function correctly if you're mixing both read and write operations with each other.

or
`yarn install smart-buffer`
## Using smart-buffer

@@ -49,3 +39,3 @@

function createLoginPacket(username, password, age, country) {
let packet = new SmartBuffer();
var packet = new SmartBuffer();
packet.writeUInt16LE(0x0060); // Login Packet Type/ID

@@ -63,3 +53,3 @@ packet.writeStringNT(username);

```javascript
let login = createLoginPacket("Josh", "secret123", 22, "United States");
var login = createLoginPacket("Josh", "secret123", 22, "United States");

@@ -73,5 +63,5 @@ // <Buffer 60 00 1e 00 4a 6f 73 68 00 73 65 63 72 65 74 31 32 33 00 16 55 6e 69 74 65 64 20 53 74 61 74 65 73 00>

let reader = SmartBuffer.fromBuffer(login);
var reader = new SmartBuffer(login);
let logininfo = {
var logininfo = {
packetType: reader.readUInt16LE(),

@@ -101,41 +91,18 @@ packetLength: reader.readUInt16LE(),

smart-buffer has a few different ways to construct an instance. Starting with version 2.0, the following factory methods are preffered.
smart-buffer has a few different constructor signatures you can use. By default, utf8 encoding is used, and the internal Buffer length will be 4096. When reading from a Buffer, smart-buffer does NOT make a copy of the Buffer. It reads from the Buffer it was given.
```javascript
let SmartBuffer = require('smart-buffer');
var SmartBuffer = require('smart-buffer');
// Creating SmartBuffer from existing Buffer
let buff = SmartBuffer.fromBuffer(buffer); // Creates instance from buffer. (Uses default utf8 encoding)
let buff = SmartBuffer.fromBuffer(buffer, 'ascii'); // Creates instance from buffer with ascii encoding for Strings.
// Reading from an existing Buffer:
var reader = new SmartBuffer(buffer);
var reader = new SmartBuffer(buffer, 'ascii');
// Creating SmartBuffer with specified internal Buffer size.
let buff = SmartBuffer.fromSize(1024); // Creates instance with internal Buffer size of 1024.
let buff = SmartBuffer.fromSize(1024, 'utf8'); // Creates instance with intenral Buffer size of 1024, and utf8 encoding.
// Creating SmartBuffer with options object. This one specifies size and encoding.
let buff = SmartBuffer.fromOptions({
size: 1024,
encoding: 'ascii'
});
// Creating SmartBuffer with options object. This one specified an existing Buffer.
let buff = SmartBuffer.fromOptions({
buff: buffer
});
// Just want a regular SmartBuffer with all default options?
let buff = new SmartBuffer();
// Writing to a new Buffer:
var writer = new SmartBuffer(); // Defaults to utf8, 4096 length internal Buffer.
var writer = new SmartBuffer(1024); // Defaults to utf8, 1024 length internal Buffer.
var writer = new SmartBuffer('ascii'); // Sets to ascii encoding, 4096 length internal buffer.
var writer = new SmartBuffer(1024, 'ascii'); // Sets to ascii encoding, 1024 length internal buffer.
```
## Backwards Compatibility:
All constructors used prior to 2.0 still are supported. However it's not recommended to use these.
```javascript
let writer = new SmartBuffer(); // Defaults to utf8, 4096 length internal Buffer.
let writer = new SmartBuffer(1024); // Defaults to utf8, 1024 length internal Buffer.
let writer = new SmartBuffer('ascii'); // Sets to ascii encoding, 4096 length internal buffer.
let writer = new SmartBuffer(1024, 'ascii'); // Sets to ascii encoding, 1024 length internal buffer.
```
## Reading Data

@@ -166,4 +133,4 @@

```javascript
let reader = new SmartBuffer(somebuffer);
let num = reader.readInt8();
var reader = new SmartBuffer(somebuffer);
var num = reader.readInt8();
```

@@ -176,3 +143,3 @@

### SmartBuffer.readStringNT( [encoding] )
> `String` **String encoding to use** - Defaults to the encoding set in the constructor.
> `String` **String encoding to use** - Defaults to the encoding set in the constructor, or utf8.

@@ -183,5 +150,5 @@ returns `String`

### SmartBuffer.readString( [length], [encoding] )
### SmartBuffer.readString( [length] )
### SmartBuffer.readString( [encoding] )
### SmartBuffer.readString( [length], [encoding] )
> `Number` **Length of the string to read**

@@ -319,3 +286,3 @@

### SmartBuffer.moveTo( position )
### SmartBuffer.skipTo( position )
> `Number` **The point to skip the read position to**

@@ -337,2 +304,7 @@

### SmartBuffer.destroy()
Attempts to destroy the smart-buffer.
returns this
## Properties

@@ -339,0 +311,0 @@

@@ -1,20 +0,10 @@

/// <reference types="node" />
/**
* Object interface for constructing new SmartBuffer instances.
*/
interface SmartBufferOptions {
encoding?: BufferEncoding;
size?: number;
buff?: Buffer;
}
// Type definitions for smart-buffer
// Project: https://github.com/JoshGlazebrook/smart-buffer
// Definitions by: Josh Glazebrook <https://github.com/JoshGlazebrook>
declare class SmartBuffer {
private buff;
length: number;
encoding: BufferEncoding;
private writeOffset;
private readOffset;
/**
* Creates a new SmartBuffer instance (defaults to utf8 encoding, 4096 internal Buffer size)
* Creates a new SmartBuffer instance (defaults to utf8 encoding)
*/

@@ -26,8 +16,6 @@ constructor();

*
* @param size { Number } The size the underlying buffer instance should be instantiated to (defaults to 4096)
* @param encoding { BufferEncoding } The string encoding to use for reading/writing strings (defaults to utf8)
*
* @deprecated The .fromXXX() factory methods are now preferred over the new instantiator method.
* @param arg1 { Number } The size the underlying buffer instance should be instantiated to (defaults to 4096)
* @param arg2 { String } The string encoding to use for reading/writing strings (defaults to utf8)
*/
constructor(size: number, encoding?: BufferEncoding);
constructor(size: number, encoding?: string);

@@ -37,7 +25,5 @@ /**

*
* @param encoding { BufferEncoding } The string encoding to use for reading/writing strings (defaults to utf8)
*
* @deprecated The .fromXXX() factory methods are now preferred over the new instantiator method.
* @param arg1 { String } The string encoding to use for reading/writing strings (defaults to utf8)
*/
constructor(encoding?: BufferEncoding);
constructor(encoding?: string);

@@ -47,400 +33,354 @@ /**

*
* @param buff { Buffer } An existing buffer instance to copy to this smart buffer instance
* @param encoding { BufferEncoding } The string encoding to use for reading/writing strings (defaults to utf8)
*
* @deprecated The .fromXXX() factory methods are now preferred over the new instantiator method.
* @param arg1 { Buffer } An existing buffer instance to copy to this smart buffer instance
* @param arg2 { String } The string encoding to use for reading/writing strings (defaults to utf8)
*/
constructor(buff: Buffer, encoding?: string);
constructor(buffer: Buffer, encoding?: string)
// Signed number readers
/**
* Creates a new SmartBuffer instance
*
* @param options { SmartBufferOptions } The SmartBufferOptions settings to use when creating the SmartBuffer instance.
*
* Reads a 8-bit signed integer
*/
constructor(options: SmartBufferOptions);
readInt8(): number;
/**
* Creates a new SmartBuffer instance with the provided internal Buffer size and optional encoding.
*
* @param size { Number } The size of the internal Buffer.
* @param encoding { String } The BufferEncoding to use for strings.
*
* @return { SmartBuffer }
* Reads a 16-bit signed integer (big endian)
*/
static fromSize(size: number, encoding?: BufferEncoding): SmartBuffer;
readInt16BE(): number;
/**
* Creates a new SmartBuffer instance with the provided Buffer and optional encoding.
*
* @param buffer { Buffer } The Buffer to use as the internal Buffer value.
* @param encoding { String } The BufferEncoding to use for strings.
*
* @return { SmartBuffer }
* Reads a 16-bit signed integer (little endian)
*/
static fromBuffer(buff: Buffer, encoding?: BufferEncoding): SmartBuffer;
readInt16LE(): number;
/**
* Creates a new SmartBuffer instance with the provided SmartBufferOptions options.
*
* @param options { SmartBufferOptions } The options to use when creating the SmartBuffer instance.
* Reads a 32-bit signed integer (big endian)
*/
static fromOptions(options: SmartBufferOptions): SmartBuffer
readInt32BE(): number;
/**
* Ensures that the internal Buffer is large enough to write data.
*
* @param minLength { Number } The minimum length of the data that needs to be written.
* @param offset { Number } The offset of the data to be written.
* Reads a 32-bit signed integer (little endian)
*/
private ensureWriteable(minLength, offset?);
readInt32LE(): number;
// Unsigned number readers
/**
* Ensures that the internal Buffer is large enough to write at least the given amount of data.
*
* @param minLength { Number } The minimum length of the data needs to be written.
* Reads a 8-bit unsigned integer
*/
private ensureCapacity(minLength);
readUInt8(): number;
/**
* Reads a numeric number value using the provided function.
*
* @param func { Function(offset: number) => number } The function to read data on the internal Buffer with.
* @param byteSize { Number } The number of bytes read.
*
* @param { Number }
* Reads a 16-bit unsigned integer (big endian)
*/
private readNumberValue(func, byteSize);
readUInt16BE(): number;
/**
* Writes a numeric number value using the provided function.
*
* @param func { Function(offset: number, offset?) => number} The function to write data on the internal Buffer with.
* @param byteSize { Number } The number of bytes written.
* @param value { Number } The number value to write.
* @param offset { Number } the offset to write the number at.
*
* Reads a 16-bit unsigned integer (little endian)
*/
private writeNumberValue(func, byteSize, value, offset?);
readUInt16LE(): number;
/**
* Reads an Int8 value from the current read position.
*
* @return { Number }
* Reads a 32-bit unsigned integer (big endian)
*/
readInt8(): number;
readUInt32BE(): number;
/**
* Reads an Int16BE value from the current read position.
*
* @return { Number }
* Reads a 32-bit unsigned integer (little endian)
*/
readInt16BE(): number;
readUInt32LE(): number;
// Floating point readers
/**
* Reads an Int16LE value from the current read position.
*
* @return { Number }
* Reads a float (big endian)
*/
readInt16LE(): number;
readFloatBE(): number;
/**
* Reads an Int32BE value from the current read position.
*
* @return { Number }
* Reads a float (little endian)
*/
readInt32BE(): number;
readFloatLE(): number;
/**
* Reads an Int32LE value from the current read position.
*
* @return { Number }
* Reads a double (big endian)
*/
readInt32LE(): number;
readDoubleBE(): number;
/**
* Writes an Int8 value to the current write position (or at optional offset).
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* Reads a double (little endian)
*/
writeInt8(value: number, offset?: number): SmartBuffer;
readDoubleLE(): number;
// String readers
/**
* Writes an Int16BE value to the current write position (or at optional offset).
* Reads a string
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param length { Number } The length of the string to read
* @param encoding { Number} The encoding to use (defaults to instance level encoding)
*/
writeInt16BE(value: number, offset?: number): SmartBuffer;
readString(length?: number, encoding?: string): string;
/**
* Writes an Int16LE value to the current write position (or at optional offset).
* Reads a null terminated string
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param encoding The encoding to use (defaults to instance level encoding)
*/
writeInt16LE(value: number, offset?: number): SmartBuffer;
readStringNT(encoding?: string): string;
// Buffer readers
/**
* Writes an Int32BE value to the current write position (or at optional offset).
* Reads binary data into a Buffer
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param len { Number } The amount of data to read
*/
writeInt32BE(value: number, offset?: number): SmartBuffer;
readBuffer(len?: number): Buffer;
/**
* Writes an Int32LE value to the current write position (or at optional offset).
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* Reads null terminated binary data into a Buffer
*/
writeInt32LE(value: number, offset?: number): SmartBuffer;
readBufferNT(): Buffer;
// Signed number writers
/**
* Reads an UInt8 value from the current read position.
* Writes a 8-bit signed integer value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readUInt8(): number;
writeInt8(value: number, offset?: number): this;
/**
* Reads an UInt16BE value from the current read position.
* Writes a 16-bit signed integer (big endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readUInt16BE(): number;
writeInt16BE(value: number, offset?: number): this;
/**
* Reads an UInt16LE value from the current read position.
* Writes a 16-bit signed integer (little endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readUInt16LE(): number;
writeInt16LE(value: number, offset?: number): this;
/**
* Reads an UInt32BE value from the current read position.
* Writes a 32-bit signed integer (big endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readUInt32BE(): number;
writeInt32BE(value: number, offset?: number): this;
/**
* Reads an UInt32LE value from the current read position.
* Writes a 32-bit signed integer (little endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readUInt32LE(): number;
writeInt32LE(value: number, offset?: number): this;
// Unsigned number writers
/**
* Writes an UInt8 value to the current write position (or at optional offset).
* Writes a 8-bit unsigned integer value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeUInt8(value: number, offset?: number): SmartBuffer;
writeUInt8(value: number, offset?: number): this;
/**
* Writes an UInt16BE value to the current write position (or at optional offset).
* Writes a 16-bit unsigned integer (big endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeUInt16BE(value: number, offset?: number): SmartBuffer;
writeUInt16BE(value: number, offset?: number): this;
/**
* Writes an UInt16LE value to the current write position (or at optional offset).
* Writes a 16-bit unsigned integer (little endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeUInt16LE(value: number, offset?: number): SmartBuffer;
writeUInt16LE(value: number, offset?: number): this;
/**
* Writes an UInt32BE value to the current write position (or at optional offset).
* Writes a 32-bit unsigned integer (big endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeUInt32BE(value: number, offset?: number): SmartBuffer;
writeUInt32BE(value: number, offset?: number): this;
/**
* Writes an UInt32LE value to the current write position (or at optional offset).
* Writes a 32-bit unsigned integer (little endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeUInt32LE(value: number, offset?: number): SmartBuffer;
writeUInt32LE(value: number, offset?: number): this;
// Floating point writers
/**
* Reads an FloatBE value from the current read position.
* Writes a float (big endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readFloatBE(): number;
writeFloatBE(value: number, offset?: number): this;
/**
* Reads an FloatLE value from the current read position.
* Writes a float (little endian) value
*
* @return { Number }
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readFloatLE(): number;
writeFloatLE(value: number, offset?: number): this;
/**
* Writes a FloatBE value to the current write position (or at optional offset).
* Writes a double (big endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeFloatBE(value: number, offset?: number): SmartBuffer;
writeDoubleBE(value: number, offset?: number): this;
/**
* Writes a FloatLE value to the current write position (or at optional offset).
* Writes a double (little endian) value
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { Number } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeFloatLE(value: number, offset?: number): SmartBuffer;
writeDoubleLE(value: number, offset?: number): this;
// String writers
/**
* Reads an DoublEBE value from the current read position.
* Writes a string
*
* @return { Number }
* @param value { String } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
readDoubleBE(): number;
/**
* Reads an DoubleLE value from the current read position.
* Writes a string
*
* @return { Number }
* @param value { String } The value to write to the buffer
* @param offset { String } The encoding to use when writing the string (defaults to instance level encoding)
*/
readDoubleLE(): number;
/**
* Writes a DoubleBE value to the current write position (or at optional offset).
* Writes a string
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { String } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
* @param encoding { String } The encoding to use when writing the string (defaults to instance level encoding)
*/
writeDoubleBE(value: number, offset?: number): SmartBuffer;
writeString(value: string, offset?: number | string, encoding?: string): this;
/**
* Writes a DoubleLE value to the current write position (or at optional offset).
* Writes a null terminated string
*
* @param value { Number } The value to write.
* @param offset { Number } The offset to write the value at.
*
* @return this
* @param value { String } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
*/
writeDoubleLE(value: number, offset?: number): SmartBuffer;
/**
* Reads a String from the current read position.
* Writes a null terminated string
*
* @param length { Number } The number of bytes to read as a String.
* @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
*
* @return { String }
* @param value { String } The value to write to the buffer
* @param offset { String } The encoding to use when writing the string (defaults to instance level encoding)
*/
readString(length?: number, encoding?: BufferEncoding): string;
/**
* Writes a String to the current write position.
* Writes a null terminated string
*
* @param value { String } The String value to write.
* @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
* @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
* @param value { String } The value to write to the buffer
* @param offset { Number } The offset position to write the value to
* @param encoding { String } The encoding to use when writing the string (defaults to instance level encoding)
*/
writeString(value: string, arg2?: number | BufferEncoding, encoding?: BufferEncoding): this;
writeStringNT(value: string, offset?: number | string, encoding?: string): this;
// Buffer writers
/**
* Reads a null-terminated String from the current read position.
* Writes a Buffer
*
* @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
*
* @return { String }
* @param value { Buffer } The Buffer to write to the smart buffer
* @param offset { Number } The offset position to write the value to
*/
readStringNT(encoding?: BufferEncoding): string;
/**
* Writes a null-terminated String to the current write position.
*
* @param value { String } The String value to write.
* @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
* @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
*/
writeStringNT(value: string, offset?: number | BufferEncoding, encoding?: BufferEncoding): void;
/**
* Reads a Buffer from the internal read position.
*
* @param length { Number } The length of data to read as a Buffer.
*
* @return { Buffer }
*/
readBuffer(length?: number): Buffer;
/**
* Writes a Buffer to the current write position.
*
* @param value { Buffer } The Buffer to write.
* @param offset { Number } The offset to write the Buffer to.
*/
writeBuffer(value: Buffer, offset?: number): this;
/**
* Reads a null-terminated Buffer from the current read poisiton.
* Writes a Buffer with null termination
*
* @return { Buffer }
* @param value { Buffer } The buffer to write to the smart buffer
* @param offset { Number } The offset position to write the value to
*/
readBufferNT(): Buffer;
/**
* Writes a null-terminated Buffer to the current write position.
*
* @param value { Buffer } The Buffer to write.
* @param offset { Number } The offset to write the Buffer to.
*/
writeBufferNT(value: Buffer, offset?: number): this;
// Misc Functions
/**
* Clears the SmartBuffer instance to its original empty state.
* Clears the smart buffer
*/
clear(): void;
clear();
/**
* Gets the remaining data left to be read from the SmartBuffer instance.
*
* @return { Number }
* Gets the number of bytes that remain to be read
*/
remaining(): number;
/**
* Moves the read offset forward.
* Increases the read offset position
*
* @param amount { Number } The amount to move the read offset forward by.
* @param amount { Number } The amount to increase the read offset position by
*/
skip(amount: number): void;
skip(amount: number);
/**
* Moves the read offset backwards.
* Changes the read offset position
*
* @param amount { Number } The amount to move the read offset backwards by.
* @param position { Number } The position to change the read offset to
*/
rewind(amount: number): void;
skipTo(position: number);
/**
* Moves the read offset to a specific position.
* Decreases the read offset position
*
* @param position { Number } The position to move the read offset to.
* @param amount { Number } The amount to decrease the read offset position by
*/
skipTo(position: number): void;
rewind(amount: number);
/**
* Moves the read offset to a specific position.
*
* @param position { Number } The position to move the read offset to.
* Gets the underlying Buffer instance
*/
moveTo(position: number): void;
/**
* Gets the value of the internal managed Buffer
*
* @param { Buffer }
*/
toBuffer(): Buffer;
/**
* Gets the String value of the internal managed Buffer
* Gets the string representation of the underlying Buffer
*
* @param encoding { String } The BufferEncoding to display the Buffer as (defaults to instance level encoding).
* @param encoding { String } The encoding to use (defaults to instance level encoding)
*/
toString(encoding?: BufferEncoding): string;
toString(encoding?: string): string;
/**
* Destroys the SmartBuffer instance.
* Destroys the smart buffer instance
*/
destroy(): void;
destroy();
/**
* Type checking function that determines if an object is a SmartBufferOptions object.
* Gets the current length of the smart buffer instance
*/
static isSmartBufferOptions(options: SmartBufferOptions): options is SmartBufferOptions;
length: number;
}
export = SmartBuffer;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc