Skip to content

feat: Added prepend and getBuffers methods. #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025

Conversation

ShogunPanda
Copy link
Contributor

This PR adds the following two methods:

  • prepend: Like append, but operates on the beginning of the list.
  • getBuffers: It returns _bufs but in a TypeScript friendly way.

@rvagg
Copy link
Owner

rvagg commented Mar 8, 2025

Can you give me a why with these please?

@ShogunPanda
Copy link
Contributor Author

Sure:

  1. prepend is useful when you are working on writing data to binary protocols that prepend the length of the rest of message. Since you might know the length of the message only after building the rest of it, you then need to somehow prepend it to an existing bl. Obviously this is under the assumption that we don't want people to mess with _bufs directly.
  2. getBuffers is mostly to make it TypeScript friendly if you need to access _bufs (for instance to traverse it) which is not currently exposed.

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit e9eda95 into rvagg:master Mar 11, 2025
15 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 11, 2025
## [6.1.0](v6.0.20...v6.1.0) (2025-03-11)

### Features

* Added prepend and getBuffers methods. ([#154](#154)) ([e9eda95](e9eda95))
Copy link

🎉 This PR is included in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ShogunPanda ShogunPanda deleted the new-methods branch March 12, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants