chore: stop using NeDB to convert pack files to JSON

This commit is contained in:
Johannes Loher 2022-11-11 14:11:59 +01:00
parent f38adb5e02
commit 986b743ab6
3 changed files with 15 additions and 140 deletions

View file

@ -75,7 +75,6 @@
"@pixi/settings": "6.2.1",
"@pixi/utils": "6.2.1",
"@rollup/plugin-typescript": "9.0.2",
"@seald-io/nedb": "3.1.0",
"@swc/core": "1.3.14",
"@types/fs-extra": "9.0.13",
"@types/node": "18.11.9",

View file

@ -4,7 +4,6 @@
import promises from "node:fs/promises";
import path from "node:path";
import Datastore from "@seald-io/nedb";
/**
* Removes unwanted data from a pack entry
@ -57,25 +56,20 @@ export async function convertJSONToPack(contents) {
/**
* Converts a pack file (NeDB) to a JSON string.
* @param {string} filename The name of the pack file
* @returns {Promise<string>} A promise that resolves to an array of the documents in the pack file
* @returns {Promise<string>} A promise that resolves to JSON string representing the pack file
*/
function convertPackFileToJSON(filename) {
const db = new Datastore({ filename, autoload: true });
return new Promise((resolve, reject) => {
db.find({}, (err, docs) => {
if (err) {
reject(err);
} else {
resolve(
JSON.stringify(
docs.map((entry) => cleanPackEntry(entry)),
undefined,
4,
) + "\n",
);
}
});
});
async function convertPackFileToJSON(filename) {
const data = await promises.readFile(filename, { flag: "r", encoding: "utf-8" });
return (
JSON.stringify(
data.split(/\r?\n/).flatMap((entry) => {
if (entry === "") return [];
return cleanPackEntry(JSON.parse(entry));
}),
undefined,
4,
) + "\n"
);
}
/**

122
yarn.lock
View file

@ -946,24 +946,6 @@ __metadata:
languageName: node
linkType: hard
"@seald-io/binary-search-tree@npm:^1.0.2":
version: 1.0.2
resolution: "@seald-io/binary-search-tree@npm:1.0.2"
checksum: 957315cbe4c7af17a6830753e933d23fddae4620e55070a179b8c3e4582021e75a171da1094a5931be4deea41c059a5f233bd76e13689afb7c4447a8d5358be7
languageName: node
linkType: hard
"@seald-io/nedb@npm:3.1.0":
version: 3.1.0
resolution: "@seald-io/nedb@npm:3.1.0"
dependencies:
"@seald-io/binary-search-tree": ^1.0.2
localforage: ^1.9.0
util: ^0.12.4
checksum: 081884b02756c8a623b9cc0907882e51a5c39f530ce02644af8b172fc0451c61e98d3582339d602f3102af8042303d1c3a912a625fc5e934a8b09998dfbf512c
languageName: node
linkType: hard
"@socket.io/base64-arraybuffer@npm:~1.0.2":
version: 1.0.2
resolution: "@socket.io/base64-arraybuffer@npm:1.0.2"
@ -1609,13 +1591,6 @@ __metadata:
languageName: node
linkType: hard
"available-typed-arrays@npm:^1.0.5":
version: 1.0.5
resolution: "available-typed-arrays@npm:1.0.5"
checksum: 20eb47b3cefd7db027b9bbb993c658abd36d4edd3fe1060e83699a03ee275b0c9b216cc076ff3f2db29073225fb70e7613987af14269ac1fe2a19803ccc97f1a
languageName: node
linkType: hard
"backo2@npm:~1.0.2":
version: 1.0.2
resolution: "backo2@npm:1.0.2"
@ -2550,7 +2525,6 @@ __metadata:
"@pixi/settings": 6.2.1
"@pixi/utils": 6.2.1
"@rollup/plugin-typescript": 9.0.2
"@seald-io/nedb": 3.1.0
"@swc/core": 1.3.14
"@types/fs-extra": 9.0.13
"@types/node": 18.11.9
@ -2681,7 +2655,7 @@ __metadata:
languageName: node
linkType: hard
"es-abstract@npm:^1.18.5, es-abstract@npm:^1.19.1":
"es-abstract@npm:^1.19.1":
version: 1.19.1
resolution: "es-abstract@npm:1.19.1"
dependencies:
@ -3311,13 +3285,6 @@ __metadata:
languageName: node
linkType: hard
"foreach@npm:^2.0.5":
version: 2.0.5
resolution: "foreach@npm:2.0.5"
checksum: dab4fbfef0b40b69ee5eab81bcb9626b8fa8b3469c8cfa26480f3e5e1ee08c40eae07048c9a967c65aeda26e774511ccc70b3f10a604c01753c6ef24361f0fc8
languageName: node
linkType: hard
"fs-extra@npm:10.1.0, fs-extra@npm:^10.1.0":
version: 10.1.0
resolution: "fs-extra@npm:10.1.0"
@ -3771,13 +3738,6 @@ __metadata:
languageName: node
linkType: hard
"immediate@npm:~3.0.5":
version: 3.0.6
resolution: "immediate@npm:3.0.6"
checksum: f9b3486477555997657f70318cc8d3416159f208bec4cca3ff3442fd266bc23f50f0c9bd8547e1371a6b5e82b821ec9a7044a4f7b944798b25aa3cc6d5e63e62
languageName: node
linkType: hard
"immutable@npm:^4.0.0":
version: 4.0.0
resolution: "immutable@npm:4.0.0"
@ -3858,16 +3818,6 @@ __metadata:
languageName: node
linkType: hard
"is-arguments@npm:^1.0.4":
version: 1.1.1
resolution: "is-arguments@npm:1.1.1"
dependencies:
call-bind: ^1.0.2
has-tostringtag: ^1.0.0
checksum: 7f02700ec2171b691ef3e4d0e3e6c0ba408e8434368504bb593d0d7c891c0dbfda6d19d30808b904a6cb1929bca648c061ba438c39f296c2a8ca083229c49f27
languageName: node
linkType: hard
"is-arrayish@npm:^0.2.1":
version: 0.2.1
resolution: "is-arrayish@npm:0.2.1"
@ -3958,15 +3908,6 @@ __metadata:
languageName: node
linkType: hard
"is-generator-function@npm:^1.0.7":
version: 1.0.10
resolution: "is-generator-function@npm:1.0.10"
dependencies:
has-tostringtag: ^1.0.0
checksum: d54644e7dbaccef15ceb1e5d91d680eb5068c9ee9f9eb0a9e04173eb5542c9b51b5ab52c5537f5703e48d5fddfd376817c1ca07a84a407b7115b769d4bdde72b
languageName: node
linkType: hard
"is-glob@npm:^4.0.0, is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1":
version: 4.0.3
resolution: "is-glob@npm:4.0.3"
@ -4092,19 +4033,6 @@ __metadata:
languageName: node
linkType: hard
"is-typed-array@npm:^1.1.3, is-typed-array@npm:^1.1.7":
version: 1.1.8
resolution: "is-typed-array@npm:1.1.8"
dependencies:
available-typed-arrays: ^1.0.5
call-bind: ^1.0.2
es-abstract: ^1.18.5
foreach: ^2.0.5
has-tostringtag: ^1.0.0
checksum: aa0f9f0716e19e2fb8aef69e69e4205479d25ace778e2339fc910948115cde4b0d9aff9d5d1e8b80f09a5664998278e05e54ad3dc9cb12cefcf86db71084ed00
languageName: node
linkType: hard
"is-weakref@npm:^1.0.1":
version: 1.0.2
resolution: "is-weakref@npm:1.0.2"
@ -4239,15 +4167,6 @@ __metadata:
languageName: node
linkType: hard
"lie@npm:3.1.1":
version: 3.1.1
resolution: "lie@npm:3.1.1"
dependencies:
immediate: ~3.0.5
checksum: 6da9f2121d2dbd15f1eca44c0c7e211e66a99c7b326ec8312645f3648935bc3a658cf0e9fa7b5f10144d9e2641500b4f55bd32754607c3de945b5f443e50ddd1
languageName: node
linkType: hard
"lilconfig@npm:2.0.5":
version: 2.0.5
resolution: "lilconfig@npm:2.0.5"
@ -4353,15 +4272,6 @@ __metadata:
languageName: node
linkType: hard
"localforage@npm:^1.9.0":
version: 1.10.0
resolution: "localforage@npm:1.10.0"
dependencies:
lie: 3.1.1
checksum: f2978b434dafff9bcb0d9498de57d97eba165402419939c944412e179cab1854782830b5ec196212560b22712d1dd03918939f59cf1d4fc1d756fca7950086cf
languageName: node
linkType: hard
"locate-path@npm:^2.0.0":
version: 2.0.0
resolution: "locate-path@npm:2.0.0"
@ -6202,7 +6112,7 @@ __metadata:
languageName: node
linkType: hard
"safe-buffer@npm:^5.1.2, safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1":
"safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1":
version: 5.1.2
resolution: "safe-buffer@npm:5.1.2"
checksum: f2f1f7943ca44a594893a852894055cf619c1fbcb611237fc39e461ae751187e7baf4dc391a72125e0ac4fb2d8c5c0b3c71529622e6a58f46b960211e704903c
@ -7089,20 +6999,6 @@ __metadata:
languageName: node
linkType: hard
"util@npm:^0.12.4":
version: 0.12.4
resolution: "util@npm:0.12.4"
dependencies:
inherits: ^2.0.3
is-arguments: ^1.0.4
is-generator-function: ^1.0.7
is-typed-array: ^1.1.3
safe-buffer: ^5.1.2
which-typed-array: ^1.1.2
checksum: 8eac7a6e6b341c0f1b3eb73bbe5dfcae31a7e9699c8fc3266789f3e95f7637946a7700dcf1904dbd3749a58a36760ebf7acf4bb5b717f7468532a8a79f44eff0
languageName: node
linkType: hard
"uuid@npm:^3.3.2":
version: 3.4.0
resolution: "uuid@npm:3.4.0"
@ -7253,20 +7149,6 @@ __metadata:
languageName: node
linkType: hard
"which-typed-array@npm:^1.1.2":
version: 1.1.7
resolution: "which-typed-array@npm:1.1.7"
dependencies:
available-typed-arrays: ^1.0.5
call-bind: ^1.0.2
es-abstract: ^1.18.5
foreach: ^2.0.5
has-tostringtag: ^1.0.0
is-typed-array: ^1.1.7
checksum: 147837cf5866e36b6b2e427731709e02f79f1578477cbde68ed773a5307520a6cb6836c73c79c30690a473266ee59010b83b6d9b25d8d677a40ff77fb37a8a84
languageName: node
linkType: hard
"which@npm:^1.2.9":
version: 1.3.1
resolution: "which@npm:1.3.1"