Skip to content

Conversation

@stereokai
Copy link

@stereokai stereokai commented Aug 26, 2023

Hi @keichi, I forked @Ericbla's binary-parser-encoder from #73 and updated it by cherry picking all the commits from this repo that were missing there. I also got all current tests passing both for the parser and the encoder.

Your binary-parser has the most developer friendly syntax out there in my opinion and it deserves an encoder to go along with it, and many users have also been showing interest in one. I'll be happy to commit for a little while to ensure this feature is implemented according to what you think is best for you and for the project.

Please let me know if you'd like to collaborate on this :)

Ericbla and others added 30 commits February 7, 2018 19:08
keichi and others added 18 commits August 25, 2023 22:42
Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.0.4 to 4.0.5.
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md)
- [Commits](socketio/socket.io-parser@4.0.4...4.0.5)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [qs](https://github.com/ljharb/qs) and [body-parser](https://github.com/expressjs/body-parser). These dependencies needed to be updated together.

Updates `qs` from 6.7.0 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](ljharb/qs@v6.7.0...v6.11.0)

Updates `body-parser` from 1.19.0 to 1.20.1
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](expressjs/body-parser@1.19.0...1.20.1)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
- dependency-name: body-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](isaacs/minimatch@v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [engine.io](https://github.com/socketio/engine.io) and [socket.io](https://github.com/socketio/socket.io). These dependencies needed to be updated together.

Updates `engine.io` from 6.1.2 to 6.2.1
- [Release notes](https://github.com/socketio/engine.io/releases)
- [Changelog](https://github.com/socketio/engine.io/blob/main/CHANGELOG.md)
- [Commits](socketio/engine.io@6.1.2...6.2.1)

Updates `socket.io` from 4.4.1 to 4.5.3
- [Release notes](https://github.com/socketio/socket.io/releases)
- [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
- [Commits](socketio/socket.io@4.4.1...4.5.3)

---
updated-dependencies:
- dependency-name: engine.io
  dependency-type: indirect
- dependency-name: socket.io
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](json5/json5@v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.31 to 0.7.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](faisalman/ua-parser-js@0.7.31...0.7.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
@JeffBusch
Copy link

Any word on this getting merged? Seems like a lot of people were looking forward to this feature...

@Kreijstal
Copy link
Contributor

Kreijstal commented Apr 7, 2024

Any word on this getting merged? Seems like a lot of people were looking forward to this feature...

They were looking for new mantainers after all.. I wouldn't pressure the mantainer lest we have the same thing like xz lmao, but I'm going to quietly use this fork instead

@stereokai not sure if this is much to ask, but can you write examples on how to use? (the encoding part)

@axi92
Copy link

axi92 commented May 22, 2024

Any thoughts on this? I think a lot of people like to use only one package instead of 2 =)
@keichi @yuhr

@stereokai
Copy link
Author

@Kreijstal check out the encoder tests in this PR which were written by the original encoder developer, @Ericbla, it's very simple and straightforward, you define a parser as usual and then just call .encode(plainOldJsObject)

@Kreijstal
Copy link
Contributor

@Kreijstal check out the encoder tests in this PR which were written by the original encoder developer, @Ericbla, it's very simple and straightforward, you define a parser as usual and then just call .encode(plainOldJsObject)

Ahh, thank you that was so simple...

@jonbarrow
Copy link

This looks REALLY nice, I'm wanting to use this fork in a project but am having some issues related to bit fields. Is there a clean way to mark the "end" of a bit field in the encoder? I've dug around the source and couldn't quite find a way to do so

There are some cases where data may be tightly packed in a way where many separate bit fields are directly next to each other, which ends up having issues since at the moment this would be treated as a single bit field and only 32 sequential bits are supported

In my case this data is Mii data from the Wii U/3DS, which makes heavy use of bit fields. This can be worked around by using .nest() with multiple parsers, but that feels a bit hacky imo?

Comment on lines +1493 to +1496
private generate_encodeSeek(ctx: Context) {
const length = ctx.generateOption(this.options.length!);
ctx.pushCode(`smartBuffer.writeBuffer(Buffer.alloc(${length}));`);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to not be compatible with parsers which use negative seek values, which is a supported feature https://github.com/keichi/binary-parser#seekreloffset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.