# buffer.Buffer

The Buffer class is a global type for dealing with binary data directly. It can be constructed in a variety of ways.

Availability
8.2.0
8.2.0
9.2.0
Extends
Object

NOTE

This is an abstract type. Any object of this structure can be used where this type is used.

# Overview

Note that this Buffer class is highly related to the Titanium.Buffer type. Both are wrappers around an underlying array of bytes and can be accessed in an array-like manner:

const value = buffer[index];
buffer[index] = 1;

In fact, this Node.js shim has been written to allow wrapping a Titanium.Buffer into a Node.js compatible instance:

const wrapped = Buffer.from(tiBuffer);

Note that this will result in a slow Buffer instance (because reads/writes pass-through to the underlying Ti.Buffer which in turn goes through the JS/native binding layer). If you only intend to read the data (or do not need to write back to the original Titanium.Buffer) you can perform a one-time copy of the underlying bytes to a faster JS-only Uint8Array:

const fastBuffer = Buffer.from(tiBuffer.toBlob().toArrayBuffer()); // here we're converting from Blob to Ti.Buffer to ArrayBuffer and the shim wraps that copy

# Properties

# buffer

Availability
8.2.0
8.2.0
9.2.0
buffer :ArrayBuffer

The underlying ArrayBuffer object based on which this Buffer object is created.

This ArrayBuffer is not guaranteed to correspond exactly to the original Buffer. See the notes on byteOffset for details.


# byteOffset

Availability
8.2.0
8.2.0
9.2.0
byteOffset :Number

The byteOffset of the Buffers underlying ArrayBuffer object.


# length

Availability
8.2.0
8.2.0
9.2.0
length :Number

Returns the number of bytes in buf.

# Methods

# compare

Availability
8.2.0
8.2.0
9.2.0
compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]]) Number

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.

0 is returned if target is the same as buf 1 is returned if target should come before buf when sorted. -1 is returned if target should come after buf when sorted.

Parameters

Name Type Description
target buffer.Buffer | Uint8Array

A Buffer or Uint8Array with which to compare buf.

targetStart Number

The offset within target at which to begin comparison.

targetEnd Number

The offset within target at which to end comparison (not inclusive).

sourceStart Number

The offset within buf at which to begin comparison.

sourceEnd Number

The offset within buf at which to end comparison (not inclusive).

Returns

Type
Number

# copy

Availability
8.2.0
8.2.0
9.2.0
copy(target[, targetStart[, sourceStart[, sourceEnd]]]) Number

Copies data from a region of buf to a region in target, even if the target memory region overlaps with buf.

Parameters

Name Type Description
target buffer.Buffer | Uint8Array

A Buffer or Uint8Array with which to compare buf.

targetStart Number

The offset within target at which to begin writing.

sourceStart Number

The offset within buf at which to begin copying.

sourceEnd Number

The offset within buf at which to stop copying (not inclusive).

Returns

The number of bytes copied.

Type
Number

# entries

Availability
8.2.0
8.2.0
9.2.0
entries() Object

Creates and returns an iterator of [index, byte] pairs from the contents of buf.

Returns

Type
Object

# equals

Availability
8.2.0
8.2.0
9.2.0
equals(otherBuffer) Boolean

Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise. Equivalent to buf.compare(otherBuffer) === 0.

Parameters

Name Type Description
otherBuffer buffer.Buffer | Uint8Array

A Buffer or Uint8Array with which to compare buf.

Returns

Type
Boolean

# fill

Availability
8.2.0
8.2.0
9.2.0
fill(value[, offset[, end[, encoding]]]) buffer.Buffer

Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.

Parameters

Name Type Description
value String | Number | buffer.Buffer | Uint8Array

The value with which to fill buf.

offset Number

Number of bytes to skip before starting to fill buf.

end Number

Where to stop filling buf (not inclusive).

encoding String

The encoding for value if value is a string.

Returns

A reference to buf.


# includes

Availability
8.2.0
8.2.0
9.2.0
includes(value[, byteOffset[, encoding]]) Boolean

Equivalent to buf.indexOf() !== -1.

Parameters

Name Type Description
value String | Number | buffer.Buffer | Uint8Array

What to search for.

byteOffset Number

Where to begin searching in buf. If negative, then offset is calculated from the end of buf.

encoding String

If value is a string, this is its encoding.

Returns

true if value was found in buf, false otherwise.

Type
Boolean

# indexOf

Availability
8.2.0
8.2.0
9.2.0
indexOf(value[, byteOffset[, encoding]]) Number

If value is:

  • a string, value is interpreted according to the character encoding in encoding.
  • a Buffer or Uint8Array, value will be used in its entirety. To compare a partial Buffer, use slice.
  • a number, value will be interpreted as an unsigned 8-bit integer value between 0 and 255.

Parameters

Name Type Description
value String | Number | buffer.Buffer | Uint8Array

What to search for.

byteOffset Number

Where to begin searching in buf. If negative, then offset is calculated from the end of buf.

encoding String

If value is a string, this is the encoding used to determine the binary representation of the string that will be searched for in buf.

Returns

The index of the first occurrence of value in buf, or -1 if buf does not contain value.

Type
Number

# keys

Availability
8.2.0
8.2.0
9.2.0
keys() Object

Creates and returns an iterator of buf keys (indices).

Returns

Type
Object

# lastIndexOf

Availability
8.2.0
8.2.0
9.2.0
lastIndexOf(value[, byteOffset[, encoding]]) Number

Identical to buf.indexOf(), except the last occurrence of value is found rather than the first occurrence.

Parameters

Name Type Description
value String | Number | buffer.Buffer | Uint8Array

What to search for.

byteOffset Number

Where to begin searching in buf. If negative, then offset is calculated from the end of buf.

encoding String

If value is a string, this is the encoding used to determine the binary representation of the string that will be searched for in buf.

Returns

The index of the last occurrence of value in buf, or -1 if buf does not contain value.

Type
Number

# readDoubleBE

Availability
8.2.0
8.2.0
9.2.0
readDoubleBE([offset]) Number

Reads a 64-bit, big-endian double from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 8.

Returns

Type
Number

# readDoubleLE

Availability
8.2.0
8.2.0
9.2.0
readDoubleLE([offset]) Number

Reads a 64-bit, little-endian double from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 8.

Returns

Type
Number

# readFloatBE

Availability
8.2.0
8.2.0
9.2.0
readFloatBE([offset]) Number

Reads a 32-bit, big-endian float from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readFloatLE

Availability
8.2.0
8.2.0
9.2.0
readFloatLE([offset]) Number

Reads a 32-bit, little-endian float from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readInt16BE

Availability
8.2.0
8.2.0
9.2.0
readInt16BE([offset]) Number

Reads a signed 16-bit, big-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2.

Returns

Type
Number

# readInt16LE

Availability
8.2.0
8.2.0
9.2.0
readInt16LE([offset]) Number

Reads a signed 16-bit, little-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2.

Returns

Type
Number

# readInt32BE

Availability
8.2.0
8.2.0
9.2.0
readInt32BE([offset]) Number

Reads a signed 32-bit, big-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readInt32LE

Availability
8.2.0
8.2.0
9.2.0
readInt32LE([offset]) Number

Reads a signed 32-bit, little-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readInt8

Availability
8.2.0
8.2.0
9.2.0
readInt8([offset]) Number

Reads a signed 8-bit integer from buf at the specified offset.

Integers read from a Buffer are interpreted as two's complement signed values.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 1.

Returns

Type
Number

# readIntBE

Availability
8.2.0
8.2.0
9.2.0
readIntBE(offset, byteLength) Number

Reads byteLength number of bytes from buf at the specified offset and interprets the result as a big-endian, two's complement signed value supporting up to 48 bits of accuracy.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to read. Must satisfy 0 < byteLength <= 6.

Returns

Type
Number

# readIntLE

Availability
8.2.0
8.2.0
9.2.0
readIntLE(offset, byteLength) Number

Reads byteLength number of bytes from buf at the specified offset and interprets the result as a little-endian, two's complement signed value supporting up to 48 bits of accuracy.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to read. Must satisfy 0 < byteLength <= 6.

Returns

Type
Number

# readUInt16BE

Availability
8.2.0
8.2.0
9.2.0
readUInt16BE([offset]) Number

Reads an unsigned 16-bit, big-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2.

Returns

Type
Number

# readUInt16LE

Availability
8.2.0
8.2.0
9.2.0
readUInt16LE([offset]) Number

Reads an unsigned 16-bit, little-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2.

Returns

Type
Number

# readUInt32BE

Availability
8.2.0
8.2.0
9.2.0
readUInt32BE([offset]) Number

Reads an unsigned 32-bit, big-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readUInt32LE

Availability
8.2.0
8.2.0
9.2.0
readUInt32LE([offset]) Number

Reads an unsigned 32-bit, little-endian integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4.

Returns

Type
Number

# readUInt8

Availability
8.2.0
8.2.0
9.2.0
readUInt8([offset]) Number

Reads an unsigned 8-bit integer from buf at the specified offset.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 1.

Returns

Type
Number

# readUIntBE

Availability
8.2.0
8.2.0
9.2.0
readUIntBE(offset, byteLength) Number

Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned big-endian value supporting up to 48 bits of accuracy.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to read. Must satisfy 0 < byteLength <= 6.

Returns

Type
Number

# readUIntLE

Availability
8.2.0
8.2.0
9.2.0
readUIntLE(offset, byteLength) Number

Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned little-endian value supporting up to 48 bits of accuracy.

Parameters

Name Type Description
offset Number

Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to read. Must satisfy 0 < byteLength <= 6.

Returns

Type
Number

# slice

Availability
8.2.0
8.2.0
9.2.0
slice([start[, end]]) buffer.Buffer

Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices.

Parameters

Name Type Description
start Number

here the new Buffer will start.

end Number

Where the new Buffer will end (not inclusive).

Returns


# subarray

Availability
8.2.0
8.2.0
9.2.0
subarray([start[, end]]) buffer.Buffer

Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices.

Parameters

Name Type Description
start Number

here the new Buffer will start.

end Number

Where the new Buffer will end (not inclusive).

Returns


# swap16

Availability
8.2.0
8.2.0
9.2.0
swap16() buffer.Buffer

Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place.

Returns


# swap32

Availability
8.2.0
8.2.0
9.2.0
swap32() buffer.Buffer

Interprets buf as an array of unsigned 32-bit integers and swaps the byte order in-place.

Returns


# swap64

Availability
8.2.0
8.2.0
9.2.0
swap64() buffer.Buffer

Interprets buf as an array of unsigned 64-bit integers and swaps the byte order in-place.

Returns


# toJSON

Availability
8.2.0
8.2.0
9.2.0
toJSON() Object

Returns a JSON representation of buf. JSON.stringify() implicitly calls this function when stringifying a Buffer instance.

Returns

Type
Object

# toString

Availability
8.2.0
8.2.0
9.2.0
toString([encoding[, start[, end]]]) 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.

Parameters

Name Type Description
encoding String

The character encoding to use.

start Number

The byte offset to start decoding at.

end Number

The byte offset to stop decoding at (not inclusive).

Returns

Type
String

# values

Availability
8.2.0
8.2.0
9.2.0
values() Object

Creates and returns an iterator for buf values (bytes). This function is called automatically when a Buffer is used in a for..of statement.

Returns

Type
Object

# write

Availability
8.2.0
8.2.0
9.2.0
write(string[, offset[, length[, encoding]]]) Number

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.

Parameters

Name Type Description
string String

String to write to buf.

offset Number

Number of bytes to skip before starting to write string.

length Number

Maximum number of bytes to write (written bytes will not exceed buf.length - offset).

encoding String

The character encoding of string.

Returns

Number of bytes written.

Type
Number

# writeDoubleBE

Availability
8.2.0
8.2.0
9.2.0
writeDoubleBE(value[, offset]) Number

Writes value to buf at the specified offset as big-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 8.

Returns

offset plus the number of bytes written.

Type
Number

# writeDoubleLE

Availability
8.2.0
8.2.0
9.2.0
writeDoubleLE(value[, offset]) Number

Writes value to buf at the specified offset as little-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 8.

Returns

offset plus the number of bytes written.

Type
Number

# writeFloatBE

Availability
8.2.0
8.2.0
9.2.0
writeFloatBE(value[, offset]) Number

Writes value to buf at the specified offset as big-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeFloatLE

Availability
8.2.0
8.2.0
9.2.0
writeFloatLE(value[, offset]) Number

Writes value to buf at the specified offset as little-endian. The value must be a JavaScript number. Behavior is undefined when value is anything other than a JavaScript number.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeInt16BE

Availability
8.2.0
8.2.0
9.2.0
writeInt16BE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

value is interpreted and written as a two's complement signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2.

Returns

offset plus the number of bytes written.

Type
Number

# writeInt16LE

Availability
8.2.0
8.2.0
9.2.0
writeInt16LE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid signed 16-bit integer. Behavior is undefined when value is anything other than a signed 16-bit integer.

value is interpreted and written as a two's complement signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2.

Returns

offset plus the number of bytes written.

Type
Number

# writeInt32BE

Availability
8.2.0
8.2.0
9.2.0
writeInt32BE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

value is interpreted and written as a two's complement signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeInt32LE

Availability
8.2.0
8.2.0
9.2.0
writeInt32LE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

value is interpreted and written as a two's complement signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeInt8

Availability
8.2.0
8.2.0
9.2.0
writeInt8(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid signed 8-bit integer. Behavior is undefined when value is anything other than a signed 8-bit integer.

value is interpreted and written as a two's complement signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 1.

Returns

offset plus the number of bytes written.

Type
Number

# writeIntBE

Availability
8.2.0
8.2.0
9.2.0
writeIntBE(value, offset, byteLength) Number

Writes byteLength bytes of value to buf at the specified offset as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than a signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to write. Must satisfy 0 < byteLength <= 6.

Returns

offset plus the number of bytes written.

Type
Number

# writeIntLE

Availability
8.2.0
8.2.0
9.2.0
writeIntLE(value, offset, byteLength) Number

Writes byteLength bytes of value to buf at the specified offset as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than a signed integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to write. Must satisfy 0 < byteLength <= 6.

Returns

offset plus the number of bytes written.

Type
Number

# writeUInt16BE

Availability
8.2.0
8.2.0
9.2.0
writeUInt16BE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid unsigned 16-bit integer. Behavior is undefined when value is anything other than an unsigned 16-bit integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2.

Returns

offset plus the number of bytes written.

Type
Number

# writeUInt16LE

Availability
8.2.0
8.2.0
9.2.0
writeUInt16LE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid unsigned 16-bit integer. Behavior is undefined when value is anything other than an unsigned 16-bit integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2.

Returns

offset plus the number of bytes written.

Type
Number

# writeUInt32BE

Availability
8.2.0
8.2.0
9.2.0
writeUInt32BE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid unsigned 32-bit integer. Behavior is undefined when value is anything other than an unsigned 32-bit integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeUInt32LE

Availability
8.2.0
8.2.0
9.2.0
writeUInt32LE(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid unsigned 32-bit integer. Behavior is undefined when value is anything other than an unsigned 32-bit integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4.

Returns

offset plus the number of bytes written.

Type
Number

# writeUInt8

Availability
8.2.0
8.2.0
9.2.0
writeUInt8(value[, offset]) Number

Writes value to buf at the specified offset. value must be a valid unsigned 8-bit integer. Behavior is undefined when value is anything other than an unsigned 8-bit integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 1.

Returns

offset plus the number of bytes written.

Type
Number

# writeUIntBE

Availability
8.2.0
8.2.0
9.2.0
writeUIntBE(value, offset, byteLength) Number

Writes byteLength bytes of value to buf at the specified offset as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than an unsigned integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to write. Must satisfy 0 < byteLength <= 6.

Returns

offset plus the number of bytes written.

Type
Number

# writeUIntLE

Availability
8.2.0
8.2.0
9.2.0
writeUIntLE(value, offset, byteLength) Number

Writes byteLength bytes of value to buf at the specified offset as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined when value is anything other than an unsigned integer.

Parameters

Name Type Description
value Number

Number to be written to buf.

offset Number

Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength.

byteLength Number

Number of bytes to write. Must satisfy 0 < byteLength <= 6.

Returns

offset plus the number of bytes written.

Type
Number