From a33eed71af136d35d805b9414e284d178c48790f Mon Sep 17 00:00:00 2001 From: Jan <66554238+vaporox@users.noreply.github.com> Date: Sun, 24 Jan 2021 11:48:03 +0100 Subject: [PATCH] refactor(Util): remove convertToBuffer (#5237) --- src/util/Util.js | 24 ------------------------ typings/index.d.ts | 2 -- 2 files changed, 26 deletions(-) diff --git a/src/util/Util.js b/src/util/Util.js index a583649d6..8d6548668 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -297,30 +297,6 @@ class Util { return given; } - /** - * Converts an ArrayBuffer or string to a Buffer. - * @param {ArrayBuffer|string} ab ArrayBuffer to convert - * @returns {Buffer} - * @private - */ - static convertToBuffer(ab) { - if (typeof ab === 'string') ab = Util.str2ab(ab); - return Buffer.from(ab); - } - - /** - * Converts a string to an ArrayBuffer. - * @param {string} str String to convert - * @returns {ArrayBuffer} - * @private - */ - static 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; - } - /** * Makes an Error from a plain info object. * @param {Object} obj Error info diff --git a/typings/index.d.ts b/typings/index.d.ts index ec55edc04..df844e77f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1559,7 +1559,6 @@ declare module 'discord.js' { public static cleanContent(str: string, message: Message): string; public static removeMentions(str: string): string; public static cloneObject(obj: object): object; - public static convertToBuffer(ab: ArrayBuffer | string): Buffer; public static delayFor(ms: number): Promise; public static discordSort( collection: Collection, @@ -1592,7 +1591,6 @@ declare module 'discord.js' { reason?: string, ): Promise<{ id: Snowflake; position: number }[]>; public static splitMessage(text: StringResolvable, options?: SplitOptions): string[]; - public static str2ab(str: string): ArrayBuffer; } class VoiceBroadcast extends EventEmitter {