@mu-online-js/mu-packet-manager
Advanced tools
Comparing version 0.0.13 to 0.0.14
41
index.js
@@ -131,8 +131,16 @@ /** | ||
// Handle chars. | ||
const match = type.match(/^char\((\d+)\)$/); | ||
if (match) { | ||
const length = parseInt(match[1]); | ||
const charsMatch = type.match(/^char\((\d+)\)$/); | ||
if (charsMatch) { | ||
const length = parseInt(charsMatch[1]); | ||
objectToStore[key] = this.buf.toString('utf8', this.currentOffset, this.currentOffset+length).replace(/\x00.*$/g, ''); | ||
this.currentOffset += length; | ||
} | ||
// Handle predefined bytes length. | ||
const byteMatch = type.match(/^byte\((\d+)\)$/); | ||
if (byteMatch) { | ||
const length = parseInt(byteMatch[1]); | ||
objectToStore[key] = this.buf.toString('utf8', this.currentOffset, this.currentOffset+length).replace(/\x00.*$/g, ''); | ||
this.currentOffset += length; | ||
} | ||
this.lastType = type; | ||
@@ -230,5 +238,5 @@ }; | ||
// Handle chars. | ||
const match = type.match(/^char\((\d+)\)$/); | ||
if (match) { | ||
const length = parseInt(match[1]); | ||
const charMatch = type.match(/^char\((\d+)\)$/); | ||
if (charMatch) { | ||
const length = parseInt(charMatch[1]); | ||
this.buf.write(value, this.currentOffset, length, 'utf8'); | ||
@@ -238,2 +246,10 @@ this.currentOffset += length; | ||
// Handle predefined bytes length. | ||
const byteMatch = type.match(/^byte\((\d+)\)$/); | ||
if (byteMatch) { | ||
const length = parseInt(byteMatch[1]); | ||
Buffer.from(value).copy(this.buf, this.currentOffset); | ||
this.currentOffset += length; | ||
} | ||
this.lastType = type; | ||
@@ -292,8 +308,15 @@ }; | ||
// Handle chars. | ||
const match = type.match(/^char\((\d+)\)$/); | ||
if (match) { | ||
const length = parseInt(match[1]); | ||
const charMatch = type.match(/^char\((\d+)\)$/); | ||
if (charMatch) { | ||
const length = parseInt(charMatch[1]); | ||
size += length; | ||
} | ||
// Handle predefined bytes length. | ||
const byteMatch = type.match(/^byte\((\d+)\)$/); | ||
if (byteMatch) { | ||
const length = parseInt(byteMatch[1]); | ||
size += length; | ||
} | ||
this.lastType = type; | ||
@@ -300,0 +323,0 @@ } |
{ | ||
"name": "@mu-online-js/mu-packet-manager", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "It allows you to define packet structures in a single place and easily convert between buffer and object representations of these structures.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11871
316