1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 04:26:00 +00:00
Files
musix-oss/node_modules/bytebuffer/src/methods/reverse.js
MatteZ02 30022c7634 Modules
2020-03-03 22:30:50 +02:00

26 lines
938 B
JavaScript

/**
* Reverses this ByteBuffer's contents.
* @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}
* @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.reverse = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
if (begin === end)
return this; // Nothing to reverse
//? if (NODE)
Array.prototype.reverse.call(this.buffer.slice(begin, end));
//? else if (DATAVIEW) {
Array.prototype.reverse.call(new Uint8Array(this.buffer).subarray(begin, end));
this.view = new DataView(this.buffer); // FIXME: Why exactly is this necessary?
//? } else {
Array.prototype.reverse.call(this.view.subarray(begin, end));
//? }
return this;
};