diff --git a/src/index.js b/src/index.js index 15e085c..4795524 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ -import parse from "./parse.js"; +import read from "./read.js"; import write from "./write.js"; -export { parse, write }; +export { read, write }; -export default { parse, write, [Symbol.toStringTag]: "NBT" }; \ No newline at end of file +export default { read, write, [Symbol.toStringTag]: "NBT" }; \ No newline at end of file diff --git a/src/parse.js b/src/read.js similarity index 93% rename from src/parse.js rename to src/read.js index 78cfddd..da65f10 100644 --- a/src/parse.js +++ b/src/read.js @@ -1,7 +1,7 @@ import { tags, types } from "./tags.js"; import { decompress } from "./compression.js"; -export default async function parse(data,{ endian } = {}){ +export default async function read(data,{ endian } = {}){ if (!data) throw new Error("Unexpected falsy value for the data parameter"); if (typeof endian !== "undefined" && !["big","little"].includes(endian)){ @@ -15,7 +15,7 @@ export default async function parse(data,{ endian } = {}){ if (typeof endian !== "undefined"){ try { - const result = await runParser(data,endian); + const result = await runReader(data,endian); return result; } catch (error){ throw error; @@ -23,10 +23,10 @@ export default async function parse(data,{ endian } = {}){ } else { let result = null; try { - result = await runParser(data,"big"); + result = await runReader(data,"big"); } catch (error){ try { - result = await runParser(data,"little"); + result = await runReader(data,"little"); } catch { throw error; } @@ -35,7 +35,7 @@ export default async function parse(data,{ endian } = {}){ } } -async function runParser(data,endian){ +async function runReader(data,endian){ if (hasGzipHeader(data)) data = await decompress(data,{ encoding: "gzip" }); const reader = new Reader(data,endian);