From 5b7964303a53e25608d19f2c90b81872eff3b68c Mon Sep 17 00:00:00 2001 From: Julia Logan Date: Tue, 2 Jul 2024 01:10:45 +0200 Subject: [PATCH] Create a sloppy packLoader that might not even work This will be useful for future version formats to parse them into a common format. --- src/packLoader.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/packLoader.js diff --git a/src/packLoader.js b/src/packLoader.js new file mode 100644 index 0000000..1fbfb7a --- /dev/null +++ b/src/packLoader.js @@ -0,0 +1,11 @@ +import { readFile } from "node:fs/promises"; + +function packLoader(file) { + return new Promise((resolve, reject) => { + readFile(file, { encoding: "utf8" }).then(contents => { + resolve(JSON.parse(contents)); + }); + }); +} + +export default packLoader;