Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/gauntlet/imports/mod.ts>Buffer

Work-in-progress front-end tool which does put a smile on my face
Latest
class Buffer
extends Uint8Array
import { Buffer } from "https://deno.land/x/gauntlet@v0.0.9/imports/mod.ts";

Constructors

new
Buffer(str: string, encoding?: string)

Allocates a new buffer containing the given {str}.

new
Buffer(size: number)

Allocates a new buffer of {size} octets.

new
Buffer(array: Uint8Array)

Allocates a new buffer containing the given {array} of octets.

new
Buffer(arrayBuffer: ArrayBuffer)

Produces a Buffer backed by the same allocated memory as the given {ArrayBuffer}.

new
Buffer(array: any[])

Allocates a new buffer containing the given {array} of octets.

new
Buffer(buffer: Buffer)

Copies the passed {buffer} data onto a new {Buffer} instance.

Properties

length: number
prototype: Buffer

Methods

compare(
otherBuffer: Uint8Array,
targetStart?: number,
targetEnd?: number,
sourceStart?: number,
sourceEnd?: number,
): number
copy(
targetBuffer: Buffer,
targetStart?: number,
sourceStart?: number,
sourceEnd?: number,
): number
equals(otherBuffer: Buffer): boolean
fill(
value: any,
offset?: number,
end?: number,
): this
includes(
value: string | number | Buffer,
byteOffset?: number,
encoding?: string,
): boolean
indexOf(
value: string | number | Buffer,
byteOffset?: number,
encoding?: string,
): number
lastIndexOf(
value: string | number | Buffer,
byteOffset?: number,
encoding?: string,
): number
readBigInt64BE(offset: number): BigInt
readBigInt64LE(offset: number): BigInt
readBigUInt64BE(offset: number): BigInt
readBigUInt64LE(offset: number): BigInt
readDoubleBE(offset: number, noAssert?: boolean): number
readDoubleLE(offset: number, noAssert?: boolean): number
readFloatBE(offset: number, noAssert?: boolean): number
readFloatLE(offset: number, noAssert?: boolean): number
readInt16BE(offset: number, noAssert?: boolean): number
readInt16LE(offset: number, noAssert?: boolean): number
readInt32BE(offset: number, noAssert?: boolean): number
readInt32LE(offset: number, noAssert?: boolean): number
readInt8(offset: number, noAssert?: boolean): number
readIntBE(
offset: number,
byteLength: number,
noAssert?: boolean,
): number
readIntLE(
offset: number,
byteLength: number,
noAssert?: boolean,
): number
readUInt16BE(offset: number, noAssert?: boolean): number
readUInt16LE(offset: number, noAssert?: boolean): number
readUInt32BE(offset: number, noAssert?: boolean): number
readUInt32LE(offset: number, noAssert?: boolean): number
readUInt8(offset: number, noAssert?: boolean): number
readUIntBE(
offset: number,
byteLength: number,
noAssert?: boolean,
): number
readUIntLE(
offset: number,
byteLength: number,
noAssert?: boolean,
): number
reverse(): this
slice(start?: number, end?: number): Buffer
toJSON(): { type: "Buffer"; data: any[]; }
toString(
encoding?: string,
start?: number,
end?: number,
): string
write(
string: string,
offset?: number,
length?: number,
encoding?: string,
): number
writeBigInt64BE(value: number, offset: number): BigInt
writeBigInt64LE(value: number, offset: number): BigInt
writeBigUInt64BE(value: number, offset: number): BigInt
writeBigUInt64LE(value: number, offset: number): BigInt
writeDoubleBE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeDoubleLE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeFloatBE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeFloatLE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeInt16BE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeInt16LE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeInt32BE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeInt32LE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeInt8(
value: number,
offset: number,
noAssert?: boolean,
): number
writeIntBE(
value: number,
offset: number,
byteLength: number,
noAssert?: boolean,
): number
writeIntLE(
value: number,
offset: number,
byteLength: number,
noAssert?: boolean,
): number
writeUInt16BE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeUInt16LE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeUInt32BE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeUInt32LE(
value: number,
offset: number,
noAssert?: boolean,
): number
writeUInt8(
value: number,
offset: number,
noAssert?: boolean,
): number
writeUIntBE(
value: number,
offset: number,
byteLength: number,
noAssert?: boolean,
): number
writeUIntLE(
value: number,
offset: number,
byteLength: number,
noAssert?: boolean,
): number

Static Methods

alloc(
size: number,
fill?: string | Buffer | number,
encoding?: string,
): Buffer

Allocates a new buffer of {size} octets.

allocUnsafe(size: number): Buffer

Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents of the newly created Buffer are unknown and may contain sensitive data.

allocUnsafeSlow(size: number): Buffer

Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents of the newly created Buffer are unknown and may contain sensitive data.

byteLength(string: string, encoding?: string): number

Gives the actual byte length of a string. encoding defaults to 'utf8'. This is not the same as String.prototype.length since that returns the number of characters in a string.

compare(buf1: Uint8Array, buf2: Uint8Array): number

The same as buf1.compare(buf2).

concat(list: Uint8Array[], totalLength?: number): Buffer

Returns a buffer which is the result of concatenating all the buffers in the list together.

If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. If the list has exactly one item, then the first item of the list is returned. If the list has more than one item, then a new Buffer is created.

from(array: any[]): Buffer

Allocates a new Buffer using an {array} of octets.

from(
arrayBuffer: ArrayBuffer,
byteOffset?: number,
length?: number,
): Buffer

When passed a reference to the .buffer property of a TypedArray instance, the newly created Buffer will share the same allocated memory as the TypedArray. The optional {byteOffset} and {length} arguments specify a memory range within the {arrayBuffer} that will be shared by the Buffer.

from(buffer: Buffer | Uint8Array): Buffer

Copies the passed {buffer} data onto a new Buffer instance.

from(str: string, encoding?: string): Buffer

Creates a new Buffer containing the given JavaScript string {str}. If provided, the {encoding} parameter identifies the character encoding. If not provided, {encoding} defaults to 'utf8'.

isBuffer(obj: any): obj is Buffer

Returns true if {obj} is a Buffer

isEncoding(encoding: string): boolean

Returns true if {encoding} is a valid encoding argument. Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'