forked from realpdai/JavaKeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytes.js
More file actions
34 lines (33 loc) · 1.34 KB
/
bytes.js
File metadata and controls
34 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Reads the specified number of bytes.
* @param {number} length Number of bytes to read
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
* @returns {!ByteBuffer}
* @expose
*/
ByteBufferPrototype.readBytes = function(length, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET('length');
}
var slice = this.slice(offset, offset + length);
//? RELATIVE('length');
return slice;
};
/**
* Writes a payload of bytes. This is an alias of {@link ByteBuffer#append}.
* @function
//? if (NODE) {
* @param {!ByteBuffer|!Buffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its
* offsets will be modified according to the performed read operation.
//? } else {
* @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its offsets
* will be modified according to the performed read operation.
//? }
* @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeBytes = ByteBufferPrototype.append;