Methods
(static) ab2str(buf, applyopt) → {string}
Convert an ArrayBuffer to a string
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
buf |
ArrayBuffer
|
Array
|
Data buffer |
|
apply |
boolean
|
<optional> |
whether or not apply supports typed arrays |
Returns:
- Type:
-
string
The string representation of the data buffer
(static) applySupportsTypedArray() → {boolean}
Determine whether String.fromCharCode.apply
supports
typed arrays as input.
Returns:
- Type:
-
boolean
Whether String.fromCharCode.apply
supports typed arrays
Example
// returns true
applySupportsTypedArray()
(private, static) endianness() → {string}
Returns the endianness of the browser
- Source:
- See:
Throws:
-
Throws Error if endianness is unknown
- Type
-
Error
Returns:
- Type:
-
string
"LE" for Little Endian and "BE" for Big Endian
Example
// returns true
const whichEndian = endianness();
whichEndian === "LE"
(static) getInt64(dataView, index, littleEndian) → {number}
Returns the 64-bit integer from the data buffer at the requested offset.
Parameters:
Name | Type | Description |
---|---|---|
dataView |
DataView
|
Data buffer |
index |
number
|
The byte offset into the data buffer |
littleEndian |
boolean
|
The endianness of the data |
Returns:
- Type:
-
number
The 64-bit integer from the dataView
(static) parseURL(url) → {object}
Internal method to create a new anchor element and uses location properties (inherent) to get the desired URL data. Some String operations are used (to normalize results across browsers).
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
Properly formatted URL |
Returns:
- Type:
-
object
Object containing URL pieces parsed out
(static) pow2(n) → {number}
Calculate $2^n$
If 31 > n >= 0 then a left-shift is used, otherwise Math.pow is used.
Parameters:
Name | Type | Description |
---|---|---|
n |
number
|
The exponent that we're raising 2 to -- i.e., 2^n |
Returns:
- Type:
-
number
The result of 2^n
Example
const result = pow2(5); // == 32
(static) str2ab(str) → {ArrayBuffer}
Convert a string to an ArrayBuffer
Parameters:
Name | Type | Description |
---|---|---|
str |
string
|
The string being turning into an ArrayBuffer |
Returns:
- Type:
-
ArrayBuffer
The ArrayBuffer representation of the string
(static) text2buffer(text, oncomplete, blocksizeopt)
Internal method to convert text from an HTTP response into an ArrayBuffer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
string
|
Text from HTTP response being converted |
||
oncomplete |
onComplete
|
Callback that will run after text is converted |
||
blocksize |
number
|
<optional> |
1024 |
How much data we're expecting |
(static) update(dst, src) → {object}
JS implementation of Python's dict.update method.
This updates object dst
with the properties in src
.
Note: This has been deprecated in v0.1.4 in favor
of the faster Object.assign(target, source)
.
Parameters:
Name | Type | Description |
---|---|---|
dst |
object
|
The object that will be updated |
src |
object
|
The object whose properties will be added to |
Returns:
- Type:
-
object
The updated dst
. This is only returned for chaining.
Example
// returns {a: 1, b: 2, c: 1, d: 3}
const d1 = {a: 1, b: 2};
const d2 = {c: 1, d: 3};
update(d1, d2) // d1 is now `{a: 1, b: 2, c: 1, d: 3}`