Skip to content
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

UR.fromBuffer Method Should Accept a type Parameter #23

Open
theanmolsharma opened this issue Aug 28, 2024 · 1 comment
Open

UR.fromBuffer Method Should Accept a type Parameter #23

theanmolsharma opened this issue Aug 28, 2024 · 1 comment

Comments

@theanmolsharma
Copy link

The fromBuffer method in the UR class currently does not accept a type parameter, which limits its flexibility. As the constructor of the UR class accepts a _type parameter, fromBuffer should also accept a type argument to allow for more versatile usage.

Current Behavior:

  • The fromBuffer method only takes a Buffer as an argument and defaults the type to 'bytes'.
public static fromBuffer(buf: Buffer) {
  return new UR(cborEncode(buf));
}

Expected Behavior:

The fromBuffer method should accept an optional type parameter that gets passed to the constructor of the UR class. If the type is not provided, it should default to 'bytes'.

Proposed Change:

public static fromBuffer(buf: Buffer, type: string = 'bytes') {
  return new UR(cborEncode(buf), type);
}

Impact:

  • This change will enhance the flexibility and usability of the UR class, making it easier to work with various types of data.
@theanmolsharma
Copy link
Author

I can work on this change if the maintainers consider it a good addition.
cc @antonispoulakis @xardass

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

No branches or pull requests

1 participant