Skip to content

Commit

Permalink
feat: add minify option to reduce pack size
Browse files Browse the repository at this point in the history
  • Loading branch information
iwtba4188 committed Jul 29, 2024
1 parent 4dad88e commit f019363
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const FILTER = {
urls: ["https://poe.ninja/api/data/*/getcharacter?*"]
};
const STATS_DATA_PATH = "./data/awakened poe trade/en_stats.json";
const STATS_DATA_PATH = "./data/awakened poe trade/en_stats.min.json";
const GEMS_DATA_PATH = "./data/com_preprocessed_gems_data.json";
const TW_GEMS_DATA_PATH = "./data/tw_preprocessed_gems_data.json";
const QUERY_PATH = "./data/query.json";
Expand Down
1 change: 1 addition & 0 deletions src/data/awakened poe trade/en_stats.min.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/scripts/json_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ def load_json(file_name: str) -> dict:
return json.load(f)


def save_json(data: dict | list, file_name: str) -> None:
def save_json(data: dict | list, file_name: str, minify: bool = False) -> None:
"""Save data to json file."""

with open(file_name, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=4)
if minify:
json.dump(data, f, ensure_ascii=False, separators=(",", ":"))
else:
json.dump(data, f, ensure_ascii=False, indent=4)
3 changes: 2 additions & 1 deletion src/scripts/transform_apt_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def sort_matcher_structure():
max_len_value = len(value)
print(f"{max_key} 數量最多,有 {max_len_value} 項")

save_json(en_table, "../data/awakened poe trade/en_stats_test.json")
save_json(en_table, "../data/awakened poe trade/en_stats.json")
save_json(en_table, "../data/awakened poe trade/en_stats.min.json", minify=True)


if __name__ == "__main__":
Expand Down

0 comments on commit f019363

Please sign in to comment.