Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ import { LocalizationParser } from "@mann-conomy/tf-parser";
})();
```

Parsing the item schema from the Steam Web API.
Parsing the client schema from the Steam Web API.

```js
import { SchemaParser } from "@mann-conomy/tf-parser";

(async() => {
try {
// Fetch the item schema from the Steam Web API
// Fetch the client schema from the Steam Web API
const response = await fetch("https://media.steampowered.com/apps/440/scripts/items/items_game.bdc614ad776fb2d43c1f247fce870485d2299152.txt");

// Resolve the response into a UTF-8 string
Expand Down
2 changes: 1 addition & 1 deletion examples/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SchemaParser } from "../src/index";

(async() => {
try {
// Fetch the item schema from the Steam Web API
// Fetch the client schema from the Steam Web API
const response = await fetch("https://media.steampowered.com/apps/440/scripts/items/items_game.bdc614ad776fb2d43c1f247fce870485d2299152.txt");

// Resolve the response into a UTF-8 string
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mann-conomy/tf-parser",
"version": "2.0.0",
"version": "2.0.1",
"description": "A Node.js parser for converting Team Fortress 2 game files to JSON objects.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions src/classes/parsers/schema.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { VDF } from "@mann-conomy/vdf-utils";
import type { ItemSchema } from "../../types/schema";
import type { ClientSchema } from "../../types/schema";

/**
* A parser for converting Team Fortress 2 item schemas to JSON objects.
* A parser for converting Team Fortress 2 client schemas to JSON objects.
*/
export default class SchemaParser {
/**
* Parses a Team Fortress 2 item schema to JSON.
* @param schema The content of a Team Fortress 2 item schema.
* @returns The item schema as a JSON object.
* @throws A RangeError if the item schema results in an empty JSON object.
* Parses a Team Fortress 2 client schema to JSON.
* @param schema The content of a Team Fortress 2 client schema.
* @returns The client schema as a JSON object.
* @throws A RangeError if the client schema results in an empty JSON object.
*/
public static parse(schema: string): ItemSchema {
return VDF.parse<ItemSchema>(schema);
public static parse(schema: string): ClientSchema {
return VDF.parse<ClientSchema>(schema);
}
}
4 changes: 2 additions & 2 deletions src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3798,9 +3798,9 @@ export interface WarDefinition {
}

/**
* Represents a Team Fortress 2 item schema parsed into a JSON object.
* Represents the Team Fortress 2 client schema parsed into a JSON object.
*/
export interface ItemSchema {
export interface ClientSchema {
items_game: {
game_info: Record<string, string>;
qualities: Record<string, ItemQuality>;
Expand Down
10 changes: 5 additions & 5 deletions test/schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe("SchemaParser", () => {
expect(parser).toBeInstanceOf(SchemaParser);
});

test("should return item schema tokens given a valid file string", () => {
test("should return client schema tokens given a valid file string", () => {
// Arrange
const file = createItemSchema();
const file = createClientSchema();

// Act
const { items_game } = SchemaParser.parse(file);
Expand Down Expand Up @@ -49,9 +49,9 @@ describe("SchemaParser", () => {
});

/**
* Creates a mock string of a Team Fortress 2 item schema.
* @returns { string } A mock string of a Team Fortress 2 item schema.
* Creates a mock string of a Team Fortress 2 client schema.
* @returns { string } A mock string of a Team Fortress 2 client schema.
*/
function createItemSchema(): string {
function createClientSchema(): string {
return "\"items_game\"\n\{\n\"qualities\"\n{\n\"vintage\"\n{\n\"value\"\t\"3\"\n}\n\"strange\"\n{\n\"value\"\t\"11\"\n}\n}";
}