-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbufferToString.ts
More file actions
33 lines (31 loc) · 911 Bytes
/
bufferToString.ts
File metadata and controls
33 lines (31 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
* Copyright © 2026 BotForge
*/
import { ArgType, NativeFunction, Return } from "../../structures"
export default new NativeFunction({
name: "$bufferToString",
version: "1.1.0",
description: "Stringifies a buffer",
unwrap: true,
brackets: true,
args: [
{
name: "variable name",
description: "The variable the buffer is allocated on",
type: ArgType.String,
required: true,
rest: false
},
{
name: "encoding",
description: "The encoding to stringify with",
type: ArgType.String,
rest: false
}
],
output: ArgType.String,
execute(ctx, [ name, encoding ]) {
return this.success(void ctx.getEnvironmentInstance(Buffer, name)?.toString(encoding as BufferEncoding || "utf-8"))
},
})