class SlowBuffer
package js.node.buffer
extends Buffer › Uint8Array
@:jsRequire("buffer","SlowBuffer")Returns an un-pooled Buffer
.
In order to avoid the garbage collection overhead of creating many individually allocated Buffer instances, by default allocations under 4KB are sliced from a single larger allocated object. This approach improves both performance and memory usage since v8 does not need to track and cleanup as many Persistent objects.
In the case where a developer may need to retain a small chunk of memory from a pool
for an indeterminate amount of time, it may be appropriate to create an un-pooled Buffer
instance
using SlowBuffer
then copy out the relevant bits.
Use of SlowBuffer
should be used only as a last resort after a developer has observed
undue memory retention in their applications.
Constructor
new(size:Int)
Allocates a new SlowBuffer
of size
bytes.
The size
must be less than or equal to the value of Buffer.kMaxLength
. Otherwise, a RangeError
is thrown.
A zero-length Buffer will be created if size <= 0.
The underlying memory for SlowBuffer
instances is not initialized. The contents of a newly created SlowBuffer
are unknown and could contain sensitive data. Use buf.fill(0)
to initialize a SlowBuffer
to zeroes.
Inherited Variables
Defined by Uint8Array
finalbuffer:ArrayBuffer
Returns the ArrayBuffer
referenced by the Uint8Array
Fixed at construction time and thus read only.
finalbyteLength:Int
Returns the length (in bytes) of the Uint8Array
from the start of its ArrayBuffer
. Fixed at construction time and thus read only.
finalbyteOffset:Int
Returns the offset (in bytes) of the Uint8Array
from the start of its ArrayBuffer
. Fixed at construction time and thus read only.
finallength:Int
Returns the number of elements hold in the Uint8Array
. Fixed at construction time and thus read only.
Inherited Methods
Defined by Buffer
compare(target:Uint8Array, ?targetStart:Int, ?targetEnd:Int, ?sourceStart:Int, ?sourceEnd:Int):Int
compare(target:Uint8Array):Int
Compares buf
with target
and returns a number indicating whether buf
comes before, after,
or is the same as target
in sort order. Comparison is based on the actual sequence of bytes in each Buffer
.
See also:
copy(target:Uint8Array, ?targetStart:Int, ?sourceStart:Int, ?sourceEnd:Int):Void
copy(target:Uint8Array):Void
Copies data from a region of buf
to a region in target
even if the target
memory region overlaps with buf
.
See also:
entries():Iterator<KeyValue<Int, Int>>
Creates and returns an iterator of [index, byte]
pairs from the contents of buf
.
See also:
equals(otherBuffer:Uint8Array):Bool
fill(value:String, ?offset:Int, ?end:Int, ?encoding:String):Buffer
fill(value:Uint8Array, ?offset:Int, ?end:Int):Buffer
fill(value:Int, ?offset:Int, ?end:Int):Buffer
Fills buf
with the specified value
. If the offset
and end
are not given, the entire buf
will be filled:
See also:
inlinehxToBytes():Bytes
Create haxe.io.Bytes
object that uses the same underlying data storage as this
buffer.
Any modifications done using the returned object will be reflected in the this
buffer.
includes(value:String, ?byteOffset:Int, ?encoding:String):Bool
includes(value:Uint8Array, ?byteOffset:Int):Bool
includes(value:Int, ?byteOffset:Int):Bool
Equivalent to buf.indexOf() !== -1
.
See also:
indexOf(value:String, ?byteOffset:Int, ?encoding:String):Int
indexOf(value:Uint8Array, ?byteOffset:Int):Int
indexOf(value:Int, ?byteOffset:Int):Int
lastIndexOf(value:String, ?byteOffset:Int, ?encoding:String):Int
lastIndexOf(value:Uint8Array, ?byteOffset:Int):Int
lastIndexOf(value:Int, ?byteOffset:Int):Int
Identical to buf.indexOf()
, except the last occurrence of value
is found
rather than the first occurrence.
See also:
readDoubleBE(?offset:Int):Float
Reads a 64-bit double from buf
at the specified offset
with specified endian format
(readDoubleBE()
returns big endian, readDoubleLE()
returns little endian).
See also:
readDoubleLE(?offset:Int):Float
Reads a 64-bit double from buf
at the specified offset
with specified endian format
(readDoubleBE()
returns big endian, readDoubleLE()
returns little endian).
See also:
readFloatBE(?offset:Int):Float
Reads a 32-bit float from buf
at the specified offset
with specified endian format
(readFloatBE()
returns big endian, readFloatLE()
returns little endian).
See also:
readFloatLE(?offset:Int):Float
Reads a 32-bit float from buf
at the specified offset
with specified endian format
(readFloatBE()
returns big endian, readFloatLE()
returns little endian).
See also:
readInt16BE(?offset:Int):Int
Reads a signed 16-bit integer from buf
at the specified offset
with the specified endian format
(readInt16BE()
returns big endian, readInt16LE()
returns little endian).
See also:
readInt16LE(?offset:Int):Int
Reads a signed 16-bit integer from buf
at the specified offset
with the specified endian format
(readInt16BE()
returns big endian, readInt16LE()
returns little endian).
See also:
readInt32BE(?offset:Int):Int
Reads a signed 32-bit integer from buf at the specified offset with the specified endian format
(readInt32BE()
returns big endian, readInt32LE()
returns little endian).
See also:
readInt32LE(?offset:Int):Int
Reads a signed 32-bit integer from buf at the specified offset with the specified endian format
(readInt32BE()
returns big endian, readInt32LE()
returns little endian).
See also:
readInt8(?offset:Int):Int
Reads a signed 8-bit integer from buf
at the specified offset
.
https://nodejs.org/api/buffer.html#buffer_buf_readint8_offset
readIntBE(offset:Int, byteLength:Int):Int
Reads byteLength
number of bytes from buf
at the specified offset
and interprets the result
as a two's complement signed value. Supports up to 48 bits of accuracy.
See also:
readIntLE(offset:Int, byteLength:Int):Int
Reads byteLength
number of bytes from buf
at the specified offset
and interprets the result
as a two's complement signed value. Supports up to 48 bits of accuracy.
See also:
readUInt16BE(?offset:Int):Int
Reads an unsigned 16-bit integer from buf
at the specified offset
with specified endian format
readUInt16BE()
returns big endian, readUInt16LE()
returns little endian).
See also:
readUInt16LE(?offset:Int):Int
Reads an unsigned 16-bit integer from buf
at the specified offset
with specified endian format
(readUInt16BE()
returns big endian, readUInt16LE()
returns little endian).
See also:
readUInt32BE(?offset:Int):Int
Reads an unsigned 32-bit integer from buf
at the specified offset
with specified endian format
(readUInt32BE()
returns big endian, readUInt32LE()
returns little endian).
See also:
readUInt32LE(?offset:Int):Int
Reads an unsigned 32-bit integer from buf
at the specified offset
with specified endian format
(readUInt32BE()
returns big endian, readUInt32LE()
returns little endian).
See also:
readUInt8(?offset:Int):Int
Reads an unsigned 8-bit integer from buf
at the specified offset
.
See also:
slice(?start:Int, ?end:Int):Buffer
Returns a new Buffer
that references the same memory as the original,
but offset and cropped by the start
and end
indices.
See also:
subarray(?start:Int, ?end:Int):Buffer
Returns a new Buffer
that references the same memory as the original,
but offset and cropped by the start
and end
indices.
See also:
swap16():Buffer
Interprets buf
as an array of unsigned 16-bit integers and swaps the
byte order in-place. Throws ERR_INVALID_BUFFER_SIZE
if buf.length
is not a multiple of 2.
See also:
swap32():Buffer
Interprets buf
as an array of unsigned 32-bit integers and swaps the
byte order in-place. Throws ERR_INVALID_BUFFER_SIZE
if buf.length
is not a multiple of 4.
See also:
swap64():Buffer
Interprets buf
as an array of 64-bit numbers and swaps byte order in-place.
Throws ERR_INVALID_BUFFER_SIZE
if buf.length
is not a multiple of 8.
See also:
toJSON():Dynamic
Returns a JSON representation of buf
. JSON.stringify()
implicitly calls
this function when stringifying a Buffer
instance.
See also:
toString():String
toString(?encoding:String, ?start:Int, ?end:Int):String
Decodes buf
to a string according to the specified character encoding in encoding
.
start
and end
may be passed to decode only a subset of buf
.
See also:
values():Iterator<Int>
Creates and returns an iterator for buf
values (bytes). This function is called automatically
when a Buffer
is used in a for..of
statement.
See also:
write(string:String, ?offset:Int, ?length:Int, ?encoding:String):Int
Writes string
to buf
at offset
according to the character encoding in encoding
.
The length
parameter is the number of bytes to write.
If buf
did not contain enough space to fit the entire string
, only part of string will be written.
However, partially encoded characters will not be written.
See also:
writeDoubleBE(value:Float, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeDoubleBE()
writes big endian, writeDoubleLE()
writes little endian).
value
should be a valid 64-bit double. Behavior is undefined when value
is anything other than a 64-bit double.
See also:
writeDoubleLE(value:Float, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeDoubleBE()
writes big endian, writeDoubleLE()
writes little endian).
value
should be a valid 64-bit double. Behavior is undefined when value
is anything other than a 64-bit double.
See also:
writeFloatBE(value:Float, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeFloatBE()
writes big endian, writeFloatLE()
writes little endian).
value
should be a valid 32-bit float. Behavior is undefined when value
is anything other than a 32-bit float.
See also:
writeFloatLE(value:Float, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeFloatBE()
writes big endian, writeFloatLE()
writes little endian).
value
should be a valid 32-bit float. Behavior is undefined when value
is anything other than a 32-bit float.
See also:
writeInt16BE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeInt16BE()
writes big endian, writeInt16LE()
writes little endian).
value
should be a valid signed 16-bit integer.
Behavior is undefined when value is anything other than a signed 16-bit integer.
See also:
writeInt16LE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeInt16BE()
writes big endian, writeInt16LE()
writes little endian).
value
should be a valid signed 16-bit integer.
Behavior is undefined when value is anything other than a signed 16-bit integer.
See also:
writeInt32BE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeInt32BE()
writes big endian, writeInt32LE()
writes little endian).
value
should be a valid signed 32-bit integer.
Behavior is undefined when value
is anything other than a signed 32-bit integer.
See also:
writeInt32LE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeInt32BE()
writes big endian, writeInt32LE()
writes little endian).
value
should be a valid signed 32-bit integer.
Behavior is undefined when value
is anything other than a signed 32-bit integer.
See also:
writeInt8(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
. value
should be a valid signed 8-bit integer.
Behavior is undefined when value
is anything other than a signed 8-bit integer.
See also:
writeIntBE(value:Int, offset:Int, byteLength:Int):Int
Writes byteLength
bytes of value
to buf
at the specified offset
.
Supports up to 48 bits of accuracy. Behavior is undefined when value
is anything other than a signed integer.
See also:
writeIntLE(value:Int, offset:Int, byteLength:Int):Int
Writes byteLength
bytes of value
to buf
at the specified offset
.
Supports up to 48 bits of accuracy. Behavior is undefined when value
is anything other than a signed integer.
See also:
writeUInt16BE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeUInt16BE()
writes big endian, writeUInt16LE()
writes little endian).
value
should be a valid unsigned 16-bit integer.
Behavior is undefined when value
is anything other than an unsigned 16-bit integer.
See also:
writeUInt16LE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeUInt16BE()
writes big endian, writeUInt16LE()
writes little endian).
value
should be a valid unsigned 16-bit integer.
Behavior is undefined when value
is anything other than an unsigned 16-bit integer.
See also:
writeUInt32BE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeUInt32BE()
writes big endian, writeUInt32LE()
writes little endian).
value
should be a valid unsigned 32-bit integer.
Behavior is undefined when value
is anything other than an unsigned 32-bit integer.
See also:
writeUInt32LE(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
with specified endian format
(writeUInt32BE()
writes big endian, writeUInt32LE()
writes little endian).
value
should be a valid unsigned 32-bit integer.
Behavior is undefined when value
is anything other than an unsigned 32-bit integer.
See also:
writeUInt8(value:Int, ?offset:Int):Void
Writes value
to buf
at the specified offset
. value
should be a valid unsigned 8-bit integer.
Behavior is undefined when value
is anything other than an unsigned 8-bit integer.
See also:
Defined by Uint8Array
copyWithin(target:Int, start:Int, ?end:Int):Uint8Array
Copies a sequence of array elements within the array. See also Array.prototype.copyWithin().
every(callback:(currentValue:Int, index:Int, array:Uint8Array) ‑> Bool, ?thisArg:Any):Bool
every(callback:(currentValue:Int) ‑> Bool, ?thisArg:Any):Bool
every(callback:(currentValue:Int, index:Int) ‑> Bool, ?thisArg:Any):Bool
Tests whether all elements in the array pass the test provided by a function. See also Array.prototype.every().
filter(callback:(element:Int, index:Int, array:Uint8Array) ‑> Bool, ?thisArg:Any):Uint8Array
filter(callback:(element:Int) ‑> Bool, ?thisArg:Any):Uint8Array
filter(callback:(element:Int, index:Int) ‑> Bool, ?thisArg:Any):Uint8Array
Creates a new array with all of the elements of this array for which the provided filtering function returns true. See also Array.prototype.filter().
find(callback:(element:Int, index:Int, array:Uint8Array) ‑> Bool, ?thisArg:Any):Null<Int>
find(callback:(element:Int) ‑> Bool, ?thisArg:Any):Null<Int>
find(callback:(element:Int, index:Int) ‑> Bool, ?thisArg:Any):Null<Int>
Returns the found value in the array, if an element in the array satisfies the provided testing function or undefined if not found. See also Array.prototype.find().
findIndex(callback:(element:Int, index:Int, array:Uint8Array) ‑> Bool, ?thisArg:Any):Int
findIndex(callback:(element:Int) ‑> Bool, ?thisArg:Any):Int
findIndex(callback:(element:Int, index:Int) ‑> Bool, ?thisArg:Any):Int
Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found. See also Array.prototype.findIndex().
forEach(callback:(element:Int, index:Int, array:Uint8Array) ‑> Void, ?thisArg:Any):Void
forEach(callback:(element:Int) ‑> Void, ?thisArg:Any):Void
forEach(callback:(element:Int, index:Int) ‑> Void, ?thisArg:Any):Void
Calls a function for each element in the array. See also Array.prototype.forEach().
join(?separator:String):String
Joins all elements of an array into a string. See also Array.prototype.join().
map(callback:(element:Int, index:Int, array:Uint8Array) ‑> Int, ?thisArg:Any):Uint8Array
map(callback:(element:Int) ‑> Int, ?thisArg:Any):Uint8Array
map(callback:(element:Int, index:Int) ‑> Int, ?thisArg:Any):Uint8Array
Creates a new array with the results of calling a provided function on every element in this array. See also Array.prototype.map().
reduce<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint8Array) ‑> T, initialValue:T):T
reduce<T>(callback:(previousValue:T, currentValue:Int) ‑> T, initialValue:T):T
reduce<T>(callback:(previousValue:T, currentValue:Int, index:Int) ‑> T, initialValue:T):T
reduce(callbackfn:(previousValue:Int, currentValue:Int) ‑> Int):Int
reduce(callbackfn:(previousValue:Int, currentValue:Int, index:Int) ‑> Int):Int
reduce(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint8Array) ‑> Int):Int
Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value. See also Array.prototype.reduce().
reduceRight<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint8Array) ‑> T, initialValue:T):T
reduceRight<T>(callback:(previousValue:T, currentValue:Int) ‑> T, initialValue:T):T
reduceRight<T>(callback:(previousValue:T, currentValue:Int, index:Int) ‑> T, initialValue:T):T
reduceRight(callbackfn:(previousValue:Int, currentValue:Int) ‑> Int):Int
reduceRight(callbackfn:(previousValue:Int, currentValue:Int, index:Int) ‑> Int):Int
reduceRight(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint8Array) ‑> Int):Int
Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value. See also Array.prototype.reduceRight().
reverse():Uint8Array
Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first. See also Array.prototype.reverse().
set(array:Array<Int>, ?offset:Int):Void
set(array:Int8Array, ?offset:Int):Void
set(array:Uint8Array, ?offset:Int):Void
set(array:Uint8ClampedArray, ?offset:Int):Void
set(array:Int16Array, ?offset:Int):Void
set(array:Uint16Array, ?offset:Int):Void
set(array:Int32Array, ?offset:Int):Void
set(array:Uint32Array, ?offset:Int):Void
set(array:Float32Array, ?offset:Int):Void
set(array:Float64Array, ?offset:Int):Void
Stores multiple values in the typed array, reading input values from a specified array.
some(callback:(element:Int, index:Int, array:Uint8Array) ‑> Bool, ?thisArg:Any):Bool
some(callback:(element:Int) ‑> Bool, ?thisArg:Any):Bool
some(callback:(element:Int, index:Int) ‑> Bool, ?thisArg:Any):Bool
Returns true if at least one element in this array satisfies the provided testing function. See also Array.prototype.some().
sort(?compareFn:(x:Int, y:Int) ‑> Int):Uint8Array
Sorts the elements of an array in place and returns the array. See also Array.prototype.sort().
toLocaleString(?locales:String, ?options:Null<NumberFormatOptions>):String
Returns a string representing the array and its elements. See also Array.prototype.toString().