mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
Replace custom ArrayBuffer converter with Buffer.from
This commit is contained in:
@@ -1,10 +1,3 @@
|
|||||||
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) {
|
function str2ab(str) {
|
||||||
const buffer = new ArrayBuffer(str.length * 2);
|
const buffer = new ArrayBuffer(str.length * 2);
|
||||||
const view = new Uint16Array(buffer);
|
const view = new Uint16Array(buffer);
|
||||||
@@ -14,5 +7,5 @@ function str2ab(str) {
|
|||||||
|
|
||||||
module.exports = function convertArrayBuffer(x) {
|
module.exports = function convertArrayBuffer(x) {
|
||||||
if (typeof x === 'string') x = str2ab(x);
|
if (typeof x === 'string') x = str2ab(x);
|
||||||
return arrayBufferToBuffer(x);
|
return Buffer.from(x);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user