Fork me on GitHub

Module binary

This module provides implementations of the Binary/ByteArray/ByteString classes defined in the Binary/B proposal.

The JavaScript Binary class serves as common base class for ByteArray and ByteString and can't be instantiated. ByteArray implements a modifiable and resizable byte buffer, while ByteString implements an immutable byte sequence. The ByteArray and ByteString constructors can take several arguments. Have a look at the proposal for details.

When passed to a Java method that expects a byte array, instances of thes class are automatically unwrapped. Use the {@link #unwrap()} method to explicitly get the wrapped Java byte array.

Class Binary

Class ByteArray

Instance Methods

Instance Properties

Class ByteString

Class String

Instance Methods


Binary ()

Abstract base class for ByteArray and ByteString


ByteArray ()

A writable byte array.


ByteArray.prototype.concat ()


ByteArray.prototype.copy ()

Copy a range of bytes from this object to another byte array.


ByteArray.prototype.decodeToString ()


ByteArray.prototype.every (fn, thisObj)

Parameters

fn
thisObj

ByteArray.prototype.filter (fn, thisObj)

Parameters

fn
thisObj

ByteArray.prototype.forEach (fn, thisObj)

Parameters

fn
thisObj

ByteArray.prototype.indexOf (sequence, [startAt])

Parameters

number|Binary sequence the number or binary to look for
number [startAt] optional index position

Returns

number the index of the first occurrence of sequence, or -1

ByteArray.prototype.lastIndexOf ()


ByteArray.prototype.length


ByteArray.prototype.map (fn, thisObj)

Parameters

fn
thisObj

ByteArray.prototype.pop ()


ByteArray.prototype.push ()


ByteArray.prototype.reduce (fn, initialValue)

Parameters

fn
initialValue

ByteArray.prototype.reduceRight (fn, initialValue)

Parameters

fn
initialValue

ByteArray.prototype.reverse ()


ByteArray.prototype.shift ()


ByteArray.prototype.slice ()


ByteArray.prototype.some (fn, thisObj)

Parameters

fn
thisObj

ByteArray.prototype.sort (fn)

Parameters

fn

ByteArray.prototype.split ()


ByteArray.prototype.toArray ()


ByteArray.prototype.toByteArray ()


ByteArray.prototype.toByteString ()


ByteArray.prototype.toString ()


ByteArray.prototype.unshift ()


ByteString ()

An immutable byte string.


String.prototype.toByteArray (charset)

Parameters

charset

String.prototype.toByteString (charset)

Parameters

charset