Skip to content

Commit

Permalink
refactor: simplify parseShapes property checks for readability Combin…
Browse files Browse the repository at this point in the history
…ed properties.P and properties.L checks with a ternary operator for type assignment (0x01 for P, 0x02 for L). Updated loop start for clarity, preserving buffer handling and core behavior.
  • Loading branch information
Ayoub-Mabrouk committed Nov 16, 2024
1 parent ea475b0 commit 031ba28
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/udt.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,14 @@ const parseShapes = (buffer, count, properties) => {
return shapes
}

if (properties.P) {
if (properties.P || properties.L) {
shapes.push({
parentOffset: -1,
figureOffset: 0,
type: 0x01
})
} else if (properties.L) {
shapes.push({
parentOffset: -1,
figureOffset: 0,
type: 0x02
type: properties.P ? 0x01 : 0x02
})
} else {
for (let i = 1; i <= count; i++) {
for (let i = 0; i < count; i++) {
shapes.push({
parentOffset: buffer.readInt32LE(buffer.position),
figureOffset: buffer.readInt32LE(buffer.position + 4),
Expand Down

0 comments on commit 031ba28

Please sign in to comment.