# buffer.Buffer

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

- Source: https://titaniumsdk.com/docs/sdk/12.6.4/buffer.Buffer
- Titanium SDK version: 12.6.4
- Kind: pseudo
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 8.2.0

Note that this `Buffer` class is highly related to the [Titanium.Buffer](https://titaniumsdk.com/docs/sdk/Titanium.Buffer.md) type. Both are wrappers around an underlying array of bytes and can be accessed in an array-like manner:

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

In fact, this Node.js shim has been written to allow wrapping a [Titanium.Buffer](https://titaniumsdk.com/docs/sdk/Titanium.Buffer.md) into a Node.js compatible instance:

``` javascript
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](https://titaniumsdk.com/docs/sdk/Titanium.Buffer.md)) you can perform a one-time copy
of the underlying bytes to a faster JS-only `Uint8Array`:

```javascript
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

- Type: ArrayBuffer
- Platforms: Android, iPhone, iPad, macOS

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 [buffer.Buffer.byteOffset](https://titaniumsdk.com/docs/sdk/buffer.Buffer.md#byteOffset) for details.

### byteOffset

- Type: Number
- Platforms: Android, iPhone, iPad, macOS

The `byteOffset` of the `Buffer`s underlying `ArrayBuffer` object.

### length

- Type: Number
- Platforms: Android, iPhone, iPad, macOS

Returns the number of bytes in buf.

## Methods

### compare

- Platforms: Android, iPhone, iPad, macOS

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:

- `target` (buffer.Buffer | Uint8Array): A `Buffer` or `Uint8Array` with which to compare buf.
- `targetStart` (Number, optional): The offset within target at which to begin comparison. Default: `0`.
- `targetEnd` (Number, optional): The offset within target at which to end comparison (not inclusive). Default: ``target.length``.
- `sourceStart` (Number, optional): The offset within buf at which to begin comparison. Default: `0`.
- `sourceEnd` (Number, optional): The offset within buf at which to end comparison (not inclusive). Default: ``buf.length``.

Returns: Number

### copy

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `target` (buffer.Buffer | Uint8Array): A `Buffer` or `Uint8Array` with which to compare buf.
- `targetStart` (Number, optional): The offset within target at which to begin writing. Default: `0`.
- `sourceStart` (Number, optional): The offset within buf at which to begin copying. Default: `0`.
- `sourceEnd` (Number, optional): The offset within buf at which to stop copying (not inclusive). Default: ``buf.length``.

Returns: Number - The number of bytes copied.

### entries

- Platforms: Android, iPhone, iPad, macOS

Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) of `[index, byte]` pairs from the contents of `buf`.

Returns: Object

### equals

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `otherBuffer` (buffer.Buffer | Uint8Array): A `Buffer` or `Uint8Array` with which to compare buf.

Returns: Boolean

### fill

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `value` (String | Number | buffer.Buffer | Uint8Array): The value with which to fill `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to fill `buf`. Default: `0`.
- `end` (Number, optional): Where to stop filling `buf` (not inclusive). Default: ``buf.length``.
- `encoding` (String, optional): The encoding for `value` if `value` is a string. Default: ``'utf8'``.

Returns: buffer.Buffer - A reference to `buf`.

### includes

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `value` (String | Number | buffer.Buffer | Uint8Array): What to search for.
- `byteOffset` (Number, optional): Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. Default: `0`.
- `encoding` (String, optional): If `value` is a string, this is its encoding. Default: ``'utf8'``.

Returns: Boolean - `true` if `value` was found in buf, `false` otherwise.

### indexOf

- Platforms: Android, iPhone, iPad, macOS

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 [buf.slice()](https://titaniumsdk.com/docs/sdk/buffer.Buffer.md#slice).
- a number, `value` will be interpreted as an unsigned 8-bit integer value between `0` and `255`.

Parameters:

- `value` (String | Number | buffer.Buffer | Uint8Array): What to search for.
- `byteOffset` (Number, optional): Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. Default: `0`.
- `encoding` (String, optional): 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`. Default: ``'utf8'``.

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

### keys

- Platforms: Android, iPhone, iPad, macOS

Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) of `buf` keys (indices).

Returns: Object

### lastIndexOf

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `value` (String | Number | buffer.Buffer | Uint8Array): What to search for.
- `byteOffset` (Number, optional): Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`. Default: ``buf.length - 1`.`.
- `encoding` (String, optional): 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`. Default: ``'utf8'``.

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

### readDoubleBE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. Default: `0`.

Returns: Number

### readDoubleLE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. Default: `0`.

Returns: Number

### readFloatBE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readFloatLE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readInt16BE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number

### readInt16LE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number

### readInt32BE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readInt32LE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readInt8

- Platforms: Android, iPhone, iPad, macOS

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:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. Default: `0`.

Returns: Number

### readIntBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number

### readIntLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number

### readUInt16BE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number

### readUInt16LE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number

### readUInt32BE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readUInt32LE

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number

### readUInt8

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `offset` (Number, optional): Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. Default: `0`.

Returns: Number

### readUIntBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number

### readUIntLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number

### slice

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `start` (Number, optional): here the new Buffer will start. Default: `0`.
- `end` (Number, optional): Where the new Buffer will end (not inclusive). Default: ``buf.length``.

Returns: buffer.Buffer

### subarray

- Platforms: Android, iPhone, iPad, macOS

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

Parameters:

- `start` (Number, optional): here the new Buffer will start. Default: `0`.
- `end` (Number, optional): Where the new Buffer will end (not inclusive). Default: ``buf.length``.

Returns: buffer.Buffer

### swap16

- Platforms: Android, iPhone, iPad, macOS

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

Returns: buffer.Buffer

### swap32

- Platforms: Android, iPhone, iPad, macOS

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

Returns: buffer.Buffer

### swap64

- Platforms: Android, iPhone, iPad, macOS

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

Returns: buffer.Buffer

### toJSON

- Platforms: Android, iPhone, iPad, macOS

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

Returns: Object

### toString

- Platforms: Android, iPhone, iPad, macOS

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:

- `encoding` (String, optional): The character encoding to use. Default: ``'utf8'``.
- `start` (Number, optional): The byte offset to start decoding at. Default: `0`.
- `end` (Number, optional): The byte offset to stop decoding at (not inclusive). Default: ``buf.length``.

Returns: String

### values

- Platforms: Android, iPhone, iPad, macOS

Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) for `buf` values (bytes). This function is called automatically when a `Buffer` is used in a `for..of` statement.

Returns: Object

### write

- Platforms: Android, iPhone, iPad, macOS

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:

- `string` (String): String to write to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write string. Default: `0`.
- `length` (Number, optional): Maximum number of bytes to write (written bytes will not exceed buf.length - offset). Default: ``buf.length - offset`.`.
- `encoding` (String, optional): The character encoding of string. Default: `utf8`.

Returns: Number - Number of bytes written.

### writeDoubleBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeDoubleLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeFloatBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeFloatLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeInt16BE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeInt16LE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeInt32BE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeInt32LE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeInt8

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeIntBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number - `offset` plus the number of bytes written.

### writeIntLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number - `offset` plus the number of bytes written.

### writeUInt16BE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeUInt16LE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeUInt32BE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeUInt32LE

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeUInt8

- Platforms: Android, iPhone, iPad, macOS

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:

- `value` (Number): Number to be written to `buf`.
- `offset` (Number, optional): Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. Default: `0`.

Returns: Number - `offset` plus the number of bytes written.

### writeUIntBE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number - `offset` plus the number of bytes written.

### writeUIntLE

- Platforms: Android, iPhone, iPad, macOS

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:

- `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: Number - `offset` plus the number of bytes written.

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

