-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Looking into restructuring the layout of the public API, both in how you import from it, and how the exported functionalities are named. When I check out how people are using the library, it seems like they don't read the documentation too closely (understandable), so they use extra API calls that don't have to be there. It seems like people want to use `NBT.parse()` more than `NBT.read()`, while one is for binary files, and one is for SNBT files. I can see how they might think `read()` is for reading from the file system, and maybe instead they think `parse()` is to just read arbitrary data. NBTify is meant to be used specifically outside of the file system though, so neither API feature would worry about that. Not all libraries are like that though, so I can see why people think that. #47 This is a demo I made the other day of how it might make sense to see the public API look. This commit experiments with that as a demo in mind. ```js // @ts-check import { Buffer } from "node:buffer"; import * as NBT from "nbtify"; const buffer = Buffer.alloc(25); const data = await NBT.readBinary(buffer); NBT.writeBinary; NBT.readString; NBT.writeString; ```
- Loading branch information
1 parent
ebe570b
commit 46d2271
Showing
8 changed files
with
34 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { readFile } from "node:fs/promises"; | ||
import { parse, stringify } from "../src/index.js"; | ||
import { readString, writeString } from "../src/index.js"; | ||
|
||
const bigtest = new URL("./nbt/bigtest.snbt", import.meta.url); | ||
|
||
const data = await readFile(bigtest); | ||
console.log(data); | ||
|
||
const result = parse(data.toString()); | ||
const result = readString(data.toString()); | ||
// console.log(result); | ||
|
||
const stringy = stringify(result, { space: 2 }); | ||
const stringy = writeString(result, { space: 2 }); | ||
console.log(stringy); |