mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
refactor(Util): remove convertToBuffer (#5237)
This commit is contained in:
@@ -297,30 +297,6 @@ class Util {
|
|||||||
return given;
|
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.
|
* Makes an Error from a plain info object.
|
||||||
* @param {Object} obj Error info
|
* @param {Object} obj Error info
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -1559,7 +1559,6 @@ declare module 'discord.js' {
|
|||||||
public static cleanContent(str: string, message: Message): string;
|
public static cleanContent(str: string, message: Message): string;
|
||||||
public static removeMentions(str: string): string;
|
public static removeMentions(str: string): string;
|
||||||
public static cloneObject(obj: object): object;
|
public static cloneObject(obj: object): object;
|
||||||
public static convertToBuffer(ab: ArrayBuffer | string): Buffer;
|
|
||||||
public static delayFor(ms: number): Promise<void>;
|
public static delayFor(ms: number): Promise<void>;
|
||||||
public static discordSort<K, V extends { rawPosition: number; id: string }>(
|
public static discordSort<K, V extends { rawPosition: number; id: string }>(
|
||||||
collection: Collection<K, V>,
|
collection: Collection<K, V>,
|
||||||
@@ -1592,7 +1591,6 @@ declare module 'discord.js' {
|
|||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<{ id: Snowflake; position: number }[]>;
|
): Promise<{ id: Snowflake; position: number }[]>;
|
||||||
public static splitMessage(text: StringResolvable, options?: SplitOptions): string[];
|
public static splitMessage(text: StringResolvable, options?: SplitOptions): string[];
|
||||||
public static str2ab(str: string): ArrayBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VoiceBroadcast extends EventEmitter {
|
class VoiceBroadcast extends EventEmitter {
|
||||||
|
|||||||
Reference in New Issue
Block a user