steamutils 1.4.41 → 1.4.42

Sign up to get free protection for your applications and to get access to all the features.
package/_steamproto.js CHANGED
@@ -1,29 +1,29 @@
1
- import path from "path";
2
- import { loadProfos } from "./helpers/protos.js";
3
- import { fileURLToPath } from "url";
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
-
7
- export class SteamProto {
8
- constructor(proto) {
9
- this._proto = proto;
10
- }
11
-
12
- toProto() {
13
- const file = loadProfos(path.join(`${__dirname}/protos/`, this._proto.filename));
14
- const root = root.loadSync(file, {
15
- keepCase: true,
16
- });
17
- return root[this._proto.name];
18
- }
19
-
20
- protoEncode(obj) {
21
- const protobuf = this.toProto();
22
- return protobuf.encode(protobuf.create(obj)).finish();
23
- }
24
-
25
- protoDecode(obj) {
26
- const protobuf = this.toProto();
27
- return protobuf.toObject(protobuf.decode(obj), { defaults: true });
28
- }
29
- }
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
3
+ import Protobuf from "protobufjs";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ export class SteamProto {
9
+ constructor(proto) {
10
+ this._proto = proto;
11
+ }
12
+
13
+ toProto() {
14
+ const root = new Protobuf.Root().loadSync(path.join(`${__dirname}/protos/`, this._proto.filename), {
15
+ keepCase: true,
16
+ });
17
+ return root[this._proto.name];
18
+ }
19
+
20
+ protoEncode(obj) {
21
+ const protobuf = this.toProto();
22
+ return protobuf.encode(protobuf.create(obj)).finish();
23
+ }
24
+
25
+ protoDecode(obj) {
26
+ const protobuf = this.toProto();
27
+ return protobuf.toObject(protobuf.decode(obj), { defaults: true });
28
+ }
29
+ }