mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 13:02:38 +00:00
Replace custom ArrayBuffer converter with Buffer.from
This commit is contained in:
parent
f485ec22b2
commit
2c26d79f50
1 changed files with 1 additions and 8 deletions
|
|
@ -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) {
|
||||
const buffer = new ArrayBuffer(str.length * 2);
|
||||
const view = new Uint16Array(buffer);
|
||||
|
|
@ -14,5 +7,5 @@ function str2ab(str) {
|
|||
|
||||
module.exports = function convertArrayBuffer(x) {
|
||||
if (typeof x === 'string') x = str2ab(x);
|
||||
return arrayBufferToBuffer(x);
|
||||
return Buffer.from(x);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue