You are reading 12.7.0. See this page in 13.4.1.
buffer
A Node.js-compatible implementation of the core buffer module
Titanium provides a number of shims and ports of core Node.js module functionality.
This module is intended to provide a Node-compatible port of the buffer.
More details on the Node.js API can be found in their buffer module documentation
Properties 3
INSPECT_MAX_BYTES
NumberThe maximum number of bytes that will be returned when buf.inspect() is called. This can be overridden by user modules.
Default: 50
kMaxLength
NumberThe largest size allowed for a single buffer.Buffer instance.
poolSize
NumberThis is the size (in bytes) of pre-allocated internal Buffer instances used for pooling. This value may be modified.
Default: 8192
Methods 9
Allocates a new Buffer of size bytes. If fill is undefined, the Buffer will be zero-filled.
| Parameters | Type | Description |
|---|---|---|
| size | Number | The desired length of the new |
| fill? | String | Number | buffer.Buffer | Uint8Array | A value to pre-fill the new |
| encoding? | String | If |
Allocates a new Buffer of size bytes.
| Parameters | Type | Description |
|---|---|---|
| size | Number | The desired length of the new |
Allocates a new Buffer of size bytes.
| Parameters | Type | Description |
|---|---|---|
| size | Number | The desired length of the new |
Returns the byte length of a string when encoded using encoding. This is not the same as String.prototype.length, which does not account for the encoding that is used to convert the string into bytes.
| Parameters | Type | Description |
|---|---|---|
| string | String | buffer.Buffer | ArrayBuffer | A value to calculate the length of. |
| encoding? | String | If |
Compares buf1 to buf2, typically for the purpose of sorting arrays of buffer.Buffer instances. This is equivalent to calling buf1.compare(buf2).
| Parameters | Type | Description |
|---|---|---|
| buf1 | buffer.Buffer | Uint8Array | A value to calculate the length of. |
| buf2 | buffer.Buffer | Uint8Array | If |
Either -1, 0, or 1, depending on the result of the comparison. See buffer.Buffer.compare for details.
Returns a new buffer.Buffer which is the result of concatenating all the buffer.Buffer instances in the list together.
If the list has no items, or if the totalLength is 0, then a new zero-length Buffer is returned.
| Parameters | Type | Description |
|---|---|---|
| list | Array<buffer.Buffer> | Array<Uint8Array> | List of |
| totalLength? | Number | Total length of the Buffer instances in list when concatenated. |
Either -1, 0, or 1, depending on the result of the comparison. See buffer.Buffer.compare for details.
Allocates a new Buffer using an array of bytes in the range 0 – 255. Array entries outside that range will be truncated to fit into it.
| Parameters | Type | Description |
|---|---|---|
| arg | Array<Number> | buffer.Buffer | String | Titanium.Buffer | Uint8Array | The array of bytes to wrap in a |
| encodingOrOffset? | String | Number | encoding of the string, or start offset of array/buffer |
| length? | Number | length of the underlying array/buffer to wrap |
Returns true if obj is a Buffer, false otherwise.
| Parameters | Type | Description |
|---|---|---|
| obj | Object | The object to check if it is a |
Returns true if encoding is the name of a supported character encoding, or false otherwise.
| Parameters | Type | Description |
|---|---|---|
| encoding | String | A character encoding name to check. |