Skip to content

v2.0.0#32

Merged
tperale merged 25 commits intomainfrom
dev
Apr 3, 2025
Merged

v2.0.0#32
tperale merged 25 commits intomainfrom
dev

Conversation

@tperale
Copy link
Owner

@tperale tperale commented Apr 3, 2025

No description provided.

tperale added 25 commits March 14, 2025 21:28
Formats such as `.wav` rely on 24 bits number. DataView doesn't support
reading and writing such number. This commits adds support for it.

This commits the following decorator to describe property as 24 bits integers:

- `@Uint24`: Unsigned 24 bits integer
- `@Int24`: Signed 24 bits integer
This package is no longer needed since the webpack dependency has been
dropped.
Improve the overall bindump functions:
  - Support bindump partial lines
  - Add docs to options
  - Fixes padding for different bases
The binread metadata have basic informations such as the offset before
and after reading the property that make it possible to dump the content
of the object.
The 'bindump' functions only use a small subset of the function made
available by the BinaryReader and it made no sense to still make it
mandatory to pass a BinaryReader object.
Emphasize that it's not contrained to hex representation.
Metadata are created and the offset before and after reading each
primitive will be logged to keep track of the position of each
properties.

Those metadata can be kept to dump the content of the bin.
This change introduce the `--dump` option to the bson example
interactive utility.

It shows how to use the metadata to dump the content of a binary
definition.
This allows to pass BinaryCursor as if they were an ArrayBufferView
and improve the compatibility between the function and make the API
easier to use.
The reader and controller code had a weird mix of function handling EOF
value mixed with code handling EOFError.

The initial reason for this was that primitive should always returns a
value, which could be an EOF, and that value could be compared.

But in the end even the `@Until` decorator would check for an EOFError
so it didn't made sense to keep it that way and made the code just more
confusing.

BREAKING CHANGE: The BinaryReader will no longer returns an EOF symbol
when reading outside of the buffer range.
If an EOFError occur in the middle of reading a relation it should be
passed up the stack.
This patch no longer rely on errors to catch EOF and instead just check
the current offset and compare it to the length of the Cursor.

Fix: #30
- Export default for the base object definition
- Use `@{Big,Little}Endian` instead of `@Endian` decorator.
A bindump of the current state of the reading is now thrown when an
error is catched during the reading phase.

The `binread` API is more flexible and allow ArrayBuffer, as well as
views or BinaryReader.

BREAKING CHANGE: The API of the binread slightly changed.
- If you need to pass arguments to the topmost definition. Create an object
  instance instead.
- The context is now passed through an option object instead of an
  argument.
The `BinaryWriter` didn't bring much and we return an ArrayBuffer
instead.

BREAKING CHANGE: `binwrite` call arguments changed.
No longer needs to pass a `BinaryWriter` to the function
@tperale tperale merged commit f628f00 into main Apr 3, 2025
3 checks passed
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.

1 participant