Skip to content

Commit

Permalink
improve: remove unnecessary parameter defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
bdkopen committed Jun 16, 2024
1 parent 522459c commit d1b29fe
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function addTypesToInterpreter (type, compiler) {
compiler.types.nbtTagName = compiler.types.shortString
}

function createProto (type, options = {}) {
function createProto (type, options) {
const compiler = new ProtoDefCompiler(options)
addTypesToCompiler(type, compiler)
return compiler.compileProtoDefSync()
Expand Down Expand Up @@ -66,19 +66,19 @@ const parseProtoName = (proto) => {
/**
* Return the proto object give the proto name and options.
*/
const getProto = (proto, options = {}) => {
const getProto = (proto, options) => {
const protoName = parseProtoName(proto)
if (options.skipChecks) {
if (options?.skipChecks) {
return protosSkipChecks[protoName]
}
return protos[protoName]
}

function writeUncompressed (value, proto = 'big', options = {}) {
function writeUncompressed (value, proto = 'big', options) {
return getProto(proto, options).createPacketBuffer('nbt', value)
}

function parseUncompressed (data, proto = 'big', options = {}) {
function parseUncompressed (data, proto = 'big', options) {
return getProto(proto, options).parsePacketBuffer('nbt', data, data.startOffset).data
}

Expand All @@ -92,7 +92,7 @@ const hasGzipHeader = function (data) {
const hasBedrockLevelHeader = (data) =>
data[1] === 0 && data[2] === 0 && data[3] === 0

async function parseAs (data, type, options = {}) {
async function parseAs (data, type, options) {
if (hasGzipHeader(data)) {
data = await new Promise((resolve, reject) => {
zlib.gunzip(data, (error, uncompressed) => {
Expand All @@ -107,7 +107,7 @@ async function parseAs (data, type, options = {}) {
return parsed
}

async function parse (data, format, callback, options = {}) {
async function parse (data, format, callback, options) {
let fmt = null
if (typeof format === 'function') {
callback = format
Expand Down

0 comments on commit d1b29fe

Please sign in to comment.