Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
prismarine-nbt
Advanced tools
Prismarine-NBT is a JavaScript parser and serializer for NBT archives, for use with Node.js. It supports big, little, and little-varint encoded NBT files.
const fs = require('fs')
const { parse, writeUncompressed } = require('prismarine-nbt')
async function main(file) {
const buffer = await fs.promises.readFile(file)
const { parsed, type } = await parse(buffer)
const json = JSON.stringify(result, null, 2)
console.log('JSON serialized:', json)
// Write it back
const outBuffer = fs.createWriteStream('file.nbt')
const newBuf = writeUncompressed(result, type)
outBuffer.write(newBuf)
outBuffer.end(() => console.log('written!'))
}
main(process.argv[2])
var fs = require('fs'),
nbt = require('prismarine-nbt');
fs.readFile('bigtest.nbt', function(error, data) {
if (error) throw error;
nbt.parse(data, function(error, data) {
console.log(data.value.stringTest.value);
console.log(data.value['nested compound test'].value);
});
});
If the data is gzipped, it is automatically decompressed, for the buffer see metadata.buffer
Takes an optionally compressed data
buffer and reads the nbt data.
If the endian format
is known, it can be specified as 'big', 'little' or 'littleVarint'. If not specified, the library will
try to sequentially load as big, little and little varint until the parse is successful. The deduced type is returned as type
.
Minecraft Java Edition uses big-endian format, and Bedrock uses little-endian.
Returns a buffer with a serialized nbt value
.
Takes a buffer data
and returns a parsed nbt value.
Returns a simplified nbt representation : keep only the value to remove one level. This loses the types so you cannot use the resulting representation to write it back to nbt.
Provides compiled protodef instances used to parse and serialize nbt
Provide the big-endian protodef instance used to parse and serialize nbt.
Provide the little-endian protodef instance used to parse and serialize little endian nbt.
Provides a way to build complex nbt structures simply:
const nbt = require('prismarine-nbt')
writePlayerNbt({
Air: nbt.short(300),
Armor: nbt.list(
nbt.comp({ Count: nbt.byte(0), Damage: nbt.short(0), Name: nbt.string("") }),
nbt.comp({ Count: nbt.byte(0), Damage: nbt.short(0), Name: nbt.string("") }),
nbt.comp({ Count: nbt.byte(0), Damage: nbt.short(0), Name: nbt.string("") }),
),
})
FAQs
A parser and serializer for NBT archives
We found that prismarine-nbt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.