mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-31 08:00:07 +00:00
* friggin webpack tho
* probably important
* add all the stuff to the package.json
* add minify builds and a nice package.json script to run it all
* clean up
* use uglify harmony branch so we can actually run minify builds that work
* update build system
* make test better
* clean up
* fix issues with compression
*
* c++ requirements in a node lib? whaaaaat?
* fix travis yml?
* put railings on voice connections
* 🖕🏻
* aaaaaa
* handle arraybuffers in the unlikely event one is sent
* support arraybuffers in resolvebuffer
* this needs to be fixed at some point
* this was fixed
* disable filename versioning if env VERSIONED is set to false
* Update ClientDataResolver.js
* Update ClientVoiceManager.js
* Update WebSocketManager.js
* Update ConvertArrayBuffer.js
* Update webpack.html
* enable compression for browser and fix ws error handler
* Update WebSocketManager.js
* everything will be okay gawdl3y
* compression is slower in browser, so rip the last three hours of my life
* Update Constants.js
* Update .gitignore
19 lines
545 B
JavaScript
19 lines
545 B
JavaScript
function arrayBufferToBuffer(ab) {
|
|
const buffer = new Buffer(ab.byteLength);
|
|
const view = new Uint8Array(ab);
|
|
for (var i = 0; i < buffer.length; ++i) buffer[i] = view[i];
|
|
return buffer;
|
|
}
|
|
|
|
function str2ab(str) {
|
|
const buffer = new ArrayBuffer(str.length * 2);
|
|
const view = new Uint16Array(buffer);
|
|
for (var i = 0, strLen = str.length; i < strLen; i++) view[i] = str.charCodeAt(i);
|
|
return buffer;
|
|
}
|
|
|
|
module.exports = function convertArrayBuffer(x) {
|
|
if (typeof x === 'string') x = str2ab(x);
|
|
return arrayBufferToBuffer(x);
|
|
};
|